Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: runtime/bin/file_impl.dart

Issue 9346015: Change file opening operation to set position at the end of the file when FileMode.APPEND is used. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _FileInputStream extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(File file) { 6 _FileInputStream(File file) {
7 _file = file.openSync(); 7 _file = file.openSync();
8 _length = _file.lengthSync(); 8 _length = _file.lengthSync();
9 _streamMarkedClosed = true; 9 _streamMarkedClosed = true;
10 _checkScheduleCallbacks(); 10 _checkScheduleCallbacks();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 _closed = true; 42 _closed = true;
43 } 43 }
44 44
45 RandomAccessFile _file; 45 RandomAccessFile _file;
46 int _length; 46 int _length;
47 bool _closed = false; 47 bool _closed = false;
48 } 48 }
49 49
50 50
51 class _FileOutputStream implements OutputStream { 51 class _FileOutputStream implements OutputStream {
52 _FileOutputStream(File file) { 52 _FileOutputStream(File file, FileMode mode) {
53 _file = file.openSync(FileMode.WRITE); 53 _file = file.openSync(mode);
54 } 54 }
55 55
56 bool write(List<int> buffer, [bool copyBuffer = false]) { 56 bool write(List<int> buffer, [bool copyBuffer = false]) {
57 return _write(buffer, 0, buffer.length); 57 return _write(buffer, 0, buffer.length);
58 } 58 }
59 59
60 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { 60 bool writeFrom(List<int> buffer, [int offset = 0, int len]) {
61 return _write( 61 return _write(
62 buffer, offset, (len == null) ? buffer.length - offset : len); 62 buffer, offset, (len == null) ? buffer.length - offset : len);
63 } 63 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 640 }
641 String result = _FileUtils.checkedFullPath(_name); 641 String result = _FileUtils.checkedFullPath(_name);
642 if (result == null) { 642 if (result == null) {
643 throw new FileIOException("fullPath failed"); 643 throw new FileIOException("fullPath failed");
644 } 644 }
645 return result; 645 return result;
646 } 646 }
647 647
648 InputStream openInputStream() => new _FileInputStream(this); 648 InputStream openInputStream() => new _FileInputStream(this);
649 649
650 OutputStream openOutputStream() => new _FileOutputStream(this); 650 OutputStream openOutputStream([FileMode mode = FileMode.WRITE]) {
651 if (mode != FileMode.WRITE &&
652 mode != FileMode.APPEND) {
653 throw new FileIOException(
654 "Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND");
655 }
656 return new _FileOutputStream(this, mode);
657 }
651 658
652 String get name() => _name; 659 String get name() => _name;
653 660
654 void set existsHandler(void handler(bool exists)) { 661 void set existsHandler(void handler(bool exists)) {
655 _existsHandler = handler; 662 _existsHandler = handler;
656 } 663 }
657 664
658 void set createHandler(void handler()) { 665 void set createHandler(void handler()) {
659 _createHandler = handler; 666 _createHandler = handler;
660 } 667 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 var _readByteHandler; 1097 var _readByteHandler;
1091 var _readListHandler; 1098 var _readListHandler;
1092 var _noPendingWriteHandler; 1099 var _noPendingWriteHandler;
1093 var _positionHandler; 1100 var _positionHandler;
1094 var _setPositionHandler; 1101 var _setPositionHandler;
1095 var _truncateHandler; 1102 var _truncateHandler;
1096 var _lengthHandler; 1103 var _lengthHandler;
1097 var _flushHandler; 1104 var _flushHandler;
1098 var _errorHandler; 1105 var _errorHandler;
1099 } 1106 }
OLDNEW
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698