-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file permissions APIs #651
Comments
What about creating a |
I would be pretty hesitant to add surface API to this library that is not supported on If someone is willing to own that, the work may as well be done in |
It's not easy to create a custom filesystem implementation just to add a few methods on top of Given the glacial rate that I think there are ways to mitigate the confusion for users, such as those in the Flutter ecosystem, who are working with filesystems that don't support certain APIs. That's already the case with watchable versus unwatchable filesystems, for example. Clear documentation and error messages will go a long way, and if it turns out that
If you'll forgive me for nitpicking a bit: I don't think designing this is really all that hard. There's prior art for this in every other widely-used language, all the way down to Windows's emulation of POSIX filesystem APIs. But it's even easier for the |
I'm looking at using this package to represent file structures that will be encoded to and from TAR files. The TAR format can represent full UNIX permissions, and in practice this is important when using them for packaging software—we want to ensure that executables in archives are marked as executable. Although this package can represent permissions through the
FileStat
object, it provides no way of setting them when using something likeMemoryFileSystem
which means I'd have no way of creating a TAR with a certain file marked as executable.Of course, this is particularly tricky because
dart:io
itself doesn't support controlling permissions in any way, and this package's API is closely based on that interface. Since dart-lang/sdk#15078 has been open for seven years now, it doesn't seem likely that that's going to change any time soon. Given that, I see two potential options (although I may be missing others):FileSystemEntity.setMode()
and.setModeSync()
methods to thepackage:file
API and implement them inMemoryFileSystem
. This would immediately satisfy my requirements, but it has a few downsides:UnsupportedError
s forLocalFileSystem
, which could confuse users. This is already true for some APIs and some filesystems, though, so it may not be that big of a deal.dart:io
's mode-setting APIs, if those APIs do get added. This could be mitigated by getting thedart:io
team to sign off on the specific APIs we use.FileSystem
will break, since they don't implement the new methods. That said, implementors of this library are at high risk of breakage anyway since any newdart:io
method will inherently break them.FileSystemEntityWithPermissions
interface that adds.setMode()
and.setModeSync()
methods, and that individual implementors can opt into. This avoids breaking existing implementors and makes it explicit that someFileSystem
s support this API and others do not. However, it has its own issues:dart:io
down the line.MemoryFileSystem
wants to statically declare that it supports permissions, it has to update every reference toFile
,Directory
, andLink
to permissions-enabled variants.as FileSystemEntityWithPermissions
every time they want to set permissions.My preference would be option 1. I'm happy to contribute an implementation if that sounds good.
The text was updated successfully, but these errors were encountered: