-
Notifications
You must be signed in to change notification settings - Fork 5
Implement writeAsBytes
for POSIX
#206
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
Implement writeAsBytes
for POSIX
#206
Conversation
const _maxInt32 = 2147483647; | ||
|
||
/// The default `mode` to use with `open` calls that may create a file. | ||
const _defaultMode = 438; // => 0666 => rw-rw-rw- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered Lasse's idea how to represent permissions: dart-lang/language#2708 (comment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might do something like that if/when I support permissions.
}; | ||
|
||
final fd = _tempFailureRetry( | ||
() => stdlibc.open(path, flags: flags, mode: _defaultMode), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that "mode" (as in mode
and in _defaultMode
) is used to represent both flags and permissions(posix "mode"). Would it be possible to use mode
only for one of those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dart:io
calls this FileMode
. The POSIX specification calls it a "flag" and the win32 API calls it dwCreationDisposition
. How about WriteOption
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I might want to revise this when I support generic file open because I'm not sure if you can have seperate read/write options or it you have to fuse them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion regarding the name for opening mode(create/append) vs permissions used for new file creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll leave it for now and revisit the naming when I implement the Windows version and add an open
method.
@@ -30,4 +54,13 @@ base class FileSystem { | |||
Uint8List readAsBytes(String path) { | |||
throw UnsupportedError('readAsBytes'); | |||
} | |||
|
|||
/// Write the given bytes to a file. | |||
void writeAsBytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has bothered dart:io calls this "write as bytes" to me it should be "write from bytes" or just "write bytes" writeBytes
. I guess it is to mirror readAsBytes
- but still...
Not sure we want to change it for this library - but just a thought...
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.