C2FO / vfs

Pluggable, extensible virtual file system for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for opening OS files that are not writable

aucampia opened this issue · comments

Currently OS files are always opened in read/write mode. In cases where files are not writable to the process this causes problems. It would be good to have some way to accomodate read only OS files.

One way this could be implemented is to add an Options varargs type to Open, and then make a read only option. Other suggestions would be appreciated.

This may be relevant to SFTP also

@aucampia - my first thought was to include this as an option as well. It might just need a bit of thought on how error handling works for some of the vfs.File interface methods when the option is enabled.

Perhaps an alternative is to make the getInternalFile() function take the file mode, and then let the consumers of that getInternalFile function (vfs.Read(), vfs.Write(), etc...) pass the required modes to perform that operation. A hybrid approach might work as well.