Open elldritch opened 6 years ago
There are some options here:
osfs
in your case) and a writeable layer (memfs
in your case). This would allow you to access osfs
without copying it to memfs
. This also works for cases where you modify files, not just delete. Afero has an implementation of this that can guide you on the implementation. osfs
with it, excluding the file you don't want.None of these are currently implemented in go-billy. I guess these might be accepted for the helper
or util
subpackages, but that's something to be discussed with @mcuadros.
Implement something like a masking fs wrapper. That is, a filesystem that is constructed with an underlying filesystem, include glob expressions and exclude glob expressions. With this, you could wrap your osfs with it, excluding the file you don't want.
"exclude glob expressions" part sounds like a commonly used pattern, kinda like .gitignore
. I'm willing to try implementing this.
I have an interesting use case where I have some functions that run over a
billy.Filesystem
and I want to run them on a directory while ignoring a specific file. Ideally, I'd be able to do this without modifying the functions and without modifying the underlying filesystem. Instead, I want to construct amemfs
from anosfs
, and then delete the ignored file from thememfs
so I can run the function on thememfs
without needing to modify this.Is this functionality difficult to implement? I couldn't find documentation on the best way to do this.