-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Background
The original design of blang/vfs did not include neither Symbolic Links (os.Symlink) nor Hard Links (os.Link). That development stopped at v1.0.0.
The fork of 3JoB/vfs upon which this package is based, added support of Symbolic links in the vfs.Filesystem interface. This is available in my lordofscripts/VFS since v1.1.0.
Proposal
A good explanation of the behavioral differences is in this GeekForGeeks article.
The following methods should be added to vfs.Filesystem:
Link()creates a hard linkSameFile()would return true if the parameters are the source & target of a hard link.
Each vfs.Filesystem implementation will do it's best to mimic the Unix behavior.
DummyFS
Will always return an error as all other calls. This is a pretty useless VFS which only serves as a template to implement your own.
OsFS
It maps all calls to the underlying OS. Therefore this will map to os.Link.
MountFS
Same behavior as other interface calls. In other words, it first seeks the mount point, and then calls the corresponding mounted VFS's Link() method.
PrefixFS
Same as all other interface calls: add the prefix to the path and forward to the interface with the prefixed path.
BucketFS
Does the same as other bucketfs.Symlink calls but takes into account the considerations detailed below.
MemFS
Does the same as other memfs.Symlink calls but takes into account the considerations detailed below.
Other Considerations
Both bucketfs.Remove and memfs.Remove should check if the file is a soft/hard link target. If so, it should ensure that the source link does not get broken by the disappearance of the target.
Additionally, both VFS implementations should check that the target of the hard link is not a directory, if so the call must throw an os.LinkError.