| Index: sdk/lib/io/file_impl.dart
|
| diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
|
| index a98d9482671625458ab35b7995bf7b0b9b3d5fb1..69f260d77bf07ce48a308450bac5994c886eb3be 100644
|
| --- a/sdk/lib/io/file_impl.dart
|
| +++ b/sdk/lib/io/file_impl.dart
|
| @@ -344,8 +344,11 @@ class _File extends FileSystemEntity implements File {
|
| Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) {
|
| if (mode != FileMode.READ &&
|
| mode != FileMode.WRITE &&
|
| - mode != FileMode.APPEND) {
|
| - return new Future.error(new ArgumentError());
|
| + mode != FileMode.APPEND &&
|
| + mode != FileMode.WRITE_ONLY &&
|
| + mode != FileMode.WRITE_ONLY_APPEND) {
|
| + return new Future.error(
|
| + new ArgumentError('Invalid file mode for this operation'));
|
| }
|
| return _IOService._dispatch(_FILE_OPEN, [path, mode._mode])
|
| .then((response) {
|
| @@ -401,10 +404,11 @@ class _File extends FileSystemEntity implements File {
|
| RandomAccessFile openSync({FileMode mode: FileMode.READ}) {
|
| if (mode != FileMode.READ &&
|
| mode != FileMode.WRITE &&
|
| - mode != FileMode.APPEND) {
|
| - throw new FileSystemException("Unknown file mode. Use FileMode.READ, "
|
| - "FileMode.WRITE or FileMode.APPEND.",
|
| - path);
|
| + mode != FileMode.APPEND &&
|
| + mode != FileMode.WRITE_ONLY &&
|
| + mode != FileMode.WRITE_ONLY_APPEND) {
|
| + return new Future.error(
|
| + new ArgumentError('Invalid file mode for this operation'));
|
| }
|
| var id = _open(path, mode._mode);
|
| throwIfError(id, "Cannot open file", path);
|
| @@ -428,9 +432,11 @@ class _File extends FileSystemEntity implements File {
|
| IOSink openWrite({FileMode mode: FileMode.WRITE,
|
| Encoding encoding: UTF8}) {
|
| if (mode != FileMode.WRITE &&
|
| - mode != FileMode.APPEND) {
|
| - throw new ArgumentError(
|
| - "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND");
|
| + mode != FileMode.APPEND &&
|
| + mode != FileMode.WRITE_ONLY &&
|
| + mode != FileMode.WRITE_ONLY_APPEND) {
|
| + return new Future.error(
|
| + new ArgumentError('Invalid file mode for this operation'));
|
| }
|
| var consumer = new _FileStreamConsumer(this, mode);
|
| return new IOSink(consumer, encoding: encoding);
|
|
|