Code Monkey home page Code Monkey logo

Comments (6)

smola avatar smola commented on May 23, 2024

@jmalloc If we add Symlink to the billy.Filesystem interface, we'd need to bump version to v3. So my proposal would be adding Symlink function to implementations in v2, and defer exposing it in billy.Filesystem.

Mimicking os.Symlink as much as possible is definitely the way to go. PRs are welcome ;-)

from go-billy.

jmalloc avatar jmalloc commented on May 23, 2024

I have a question about the behaviour of the subdir filesystem and how best to implement Symlink() there. First some background; subdir.New() doesn't create the subdirFs.base sub-directory on the underlying filesystem. As best I can tell, this doesn't usually present any problem because:

  • Filesystem.Create() creates all parent directories when the O_CREATE flag is set.
  • There is no Filesystem.Mkdir() only MkdirAll(), and hence no way that directory creation can fail just because subdirFs.base does not exist.

This presents a small problem for Symlink(), which always fails because the base directory is never created. In light of that, should I:

  1. Create subdirFs.base if it does not exist. This most closely mirrors the behaviour of the standard library insofar as Symlink() will fail if anything deeper than base does not exist.
  2. Create all necessary parent directories in all FS implementations. This more closely mirrors the behaviour of Filesystem.Create().

I'll proceed with option (2) for now to best maintain consistency within Billy's API. Please let me know if some other behaviour is more desirable.

Note: Just like osfs.OS.Create(), any directories created will remain if symlink creation fails.

As an aside, my comment about not being able to create symlinks to non-existent files with os.Symlink() appears to be a blatant lie ;)

from go-billy.

smola avatar smola commented on May 23, 2024

@jmalloc SubdirFs should just delegate the Symlink call to the underlying filesystem if it does implement the Symlink function, or return an error otherwise.

Then the underlying filesystem should create directories as needed.

from go-billy.

smola avatar smola commented on May 23, 2024

@jmalloc Are you working on this? Feel free to create a partial PR to get further feedback, we can also help completing it.

from go-billy.

jmalloc avatar jmalloc commented on May 23, 2024

I am. I have implementations for theos and subdir filesystems, but I haven't yet found time to complete the memory-based implementation. I'm submit a PR with what I have so far when I get a chance.

from go-billy.

smola avatar smola commented on May 23, 2024

@jmalloc Thank you! We'll review it soon and figure out how to move it forward.

from go-billy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.