Skip to content

Conversation

brianquinlan
Copy link
Contributor


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

const _maxInt32 = 2147483647;

/// The default `mode` to use with `open` calls that may create a file.
const _defaultMode = 438; // => 0666 => rw-rw-rw-
Copy link

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) ?

Copy link
Contributor Author

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),
Copy link

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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.

@brianquinlan brianquinlan merged commit 139c7f7 into dart-lang:main Apr 1, 2025
15 checks passed
@@ -30,4 +54,13 @@ base class FileSystem {
Uint8List readAsBytes(String path) {
throw UnsupportedError('readAsBytes');
}

/// Write the given bytes to a file.
void writeAsBytes(
Copy link
Contributor

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants