Chromium Code Reviews| Index: runtime/bin/file_impl.dart |
| =================================================================== |
| --- runtime/bin/file_impl.dart (revision 3943) |
| +++ runtime/bin/file_impl.dart (working copy) |
| @@ -49,8 +49,8 @@ |
| class _FileOutputStream implements OutputStream { |
| - _FileOutputStream(File file) { |
| - _file = file.openSync(FileMode.WRITE); |
| + _FileOutputStream(File file, FileMode mode) { |
| + _file = file.openSync(mode); |
| } |
| bool write(List<int> buffer, [bool copyBuffer = false]) { |
| @@ -591,6 +591,9 @@ |
| } |
| if (id != 0) { |
| var randomAccessFile = new _RandomAccessFile(id, _name); |
| + if (mode == FileMode.APPEND) { |
| + _FileUtils.setPosition(id, _FileUtils.length(id)); |
|
Mads Ager (google)
2012/02/07 08:37:31
Please do this in the C++ code instead. Here you a
ricow1
2012/02/07 09:16:22
Done, I placed these in the platform specific file
|
| + } |
| handler(randomAccessFile); |
| } else if (_errorHandler != null) { |
| _errorHandler("Cannot open file: $_name"); |
| @@ -615,6 +618,9 @@ |
| if (id == 0) { |
| throw new FileIOException("Cannot open file: $_name"); |
| } |
| + if (mode == FileMode.APPEND) { |
| + _FileUtils.setPosition(id, _FileUtils.length(id)); |
|
Mads Ager (google)
2012/02/07 08:37:31
Ditto. This is actually fine because this is the s
ricow1
2012/02/07 09:16:22
Done.
|
| + } |
| return new _RandomAccessFile(id, _name); |
| } |
| @@ -647,7 +653,14 @@ |
| InputStream openInputStream() => new _FileInputStream(this); |
| - OutputStream openOutputStream() => new _FileOutputStream(this); |
| + OutputStream openOutputStream([FileMode mode = FileMode.WRITE]) { |
| + if (mode != FileMode.WRITE && |
| + mode != FileMode.APPEND) { |
| + throw new FileIOException( |
| + "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND"); |
| + } |
| + return new _FileOutputStream(this, mode); |
| + } |
| String get name() => _name; |