Skip to content

Add new relpath filesystem#417

Closed
purpleidea wants to merge 1 commit into
spf13:masterfrom
purpleidea:feat/relpathfs
Closed

Add new relpath filesystem#417
purpleidea wants to merge 1 commit into
spf13:masterfrom
purpleidea:feat/relpathfs

Conversation

@purpleidea

Copy link
Copy Markdown

This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.

This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@purpleidea

Copy link
Copy Markdown
Author

Sorry CLA's are a rude form of asymmetrical power against contributors who are giving you something for free. There's no good reason for a CLA here.

purpleidea added a commit to purpleidea/mgmt that referenced this pull request Feb 22, 2024
This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.

The upstream requires a CLA, so we'll just store this here instead.
spf13/afero#417
purpleidea added a commit to purpleidea/mgmt that referenced this pull request Feb 22, 2024
This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.

The upstream requires a CLA, so we'll just store this here instead.
spf13/afero#417
purpleidea added a commit to purpleidea/mgmt that referenced this pull request Feb 22, 2024
This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.

The upstream requires a CLA, so we'll just store this here instead.
spf13/afero#417
@CrimsonFez

Copy link
Copy Markdown

Sorry CLA's are a rude form of asymmetrical power against contributors who are giving you something for free. There's no good reason for a CLA here.

Did you actually read it??? They just want you to verify that you have the rights to the code you're submitting.

@spf13

spf13 commented May 7, 2026

Copy link
Copy Markdown
Owner

Two issues before this can move forward:

  1. CLA not signed. Please sign the CLA at https://cla-assistant.io/spf13/afero — required for all contributions.

  2. TrimPrefix without HasPrefix guard. RealPath calls strings.TrimPrefix(name, r.prefix) unconditionally. If a caller passes a path that doesn't start with the configured prefix, the path is returned unchanged rather than an error being returned. There's a commented-out guard in your code suggesting you were aware of this — it should be enforced. Something like:

    if !strings.HasPrefix(name, r.prefix) {
        return name, os.ErrNotExist
    }
  3. No tests. RelPathFs needs at least a table-driven test covering: paths that have the prefix (should strip), paths that don't have the prefix (should error), and Name() on a file (should add prefix back).

The concept is valid and distinct from BasePathFs (which prepends; this strips). Fix the above and it's a reasonable addition.

@spf13

spf13 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Closing with thanks — the use case you identified (bridging between absolute and relative path spaces, particularly for embed.FS) is real and valid. However, this is now better addressed by the NewBridgeIOFS adapter (#575), which lets you import any io/fs.FS directly as an afero.Fs. That's the direction the project is taking for this problem. Thanks for identifying the gap early.

@spf13 spf13 closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants