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

Side by Side Diff: sdk/lib/io/file_impl.dart

Issue 2698813002: [dart:io][windows] Make unicode characters display correctly. (Closed)
Patch Set: Address comments Created 3 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
« no previous file with comments | « runtime/bin/utils_win.h ('k') | sdk/lib/io/stdio.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 read(int bytes); 636 read(int bytes);
637 readInto(List<int> buffer, int start, int end); 637 readInto(List<int> buffer, int start, int end);
638 writeByte(int value); 638 writeByte(int value);
639 writeFrom(List<int> buffer, int start, int end); 639 writeFrom(List<int> buffer, int start, int end);
640 position(); 640 position();
641 setPosition(int position); 641 setPosition(int position);
642 truncate(int length); 642 truncate(int length);
643 length(); 643 length();
644 flush(); 644 flush();
645 lock(int lock, int start, int end); 645 lock(int lock, int start, int end);
646 setTranslation(int translation);
646 } 647 }
647 648
649
650 /**
651 * The translation mode of a File.
652 *
653 * Whether the data written to a file should be interpreted as text
654 * or binary data. This distinction is only meaningful on platforms that
655 * recognize a difference, in particular on Windows.
656 */
657 enum _FileTranslation {
658 /// Data should be interpreted as text.
659 text,
660 /// Data should be interpreted as binary data.
661 binary,
662 }
663
664
648 class _RandomAccessFile implements RandomAccessFile { 665 class _RandomAccessFile implements RandomAccessFile {
649 static bool _connectedResourceHandler = false; 666 static bool _connectedResourceHandler = false;
650 667
651 final String path; 668 final String path;
652 669
653 bool _asyncDispatched = false; 670 bool _asyncDispatched = false;
654 SendPort _fileService; 671 SendPort _fileService;
655 672
656 _FileResourceInfo _resourceInfo; 673 _FileResourceInfo _resourceInfo;
657 _RandomAccessFileOps _ops; 674 _RandomAccessFileOps _ops;
658 675
676 _FileTranslation _translation;
677
659 _RandomAccessFile(int pointer, this.path) { 678 _RandomAccessFile(int pointer, this.path) {
660 _ops = new _RandomAccessFileOps(pointer); 679 _ops = new _RandomAccessFileOps(pointer);
661 _resourceInfo = new _FileResourceInfo(this); 680 _resourceInfo = new _FileResourceInfo(this);
681 _translation = _FileTranslation.binary;
662 _maybeConnectHandler(); 682 _maybeConnectHandler();
663 } 683 }
664 684
665 void _maybePerformCleanup() { 685 void _maybePerformCleanup() {
666 if (closed) { 686 if (closed) {
667 _FileResourceInfo.FileClosed(_resourceInfo); 687 _FileResourceInfo.FileClosed(_resourceInfo);
668 } 688 }
669 } 689 }
670 690
671 _maybeConnectHandler() { 691 _maybeConnectHandler() {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1072 }
1053 if (start == end) { 1073 if (start == end) {
1054 throw new ArgumentError(); 1074 throw new ArgumentError();
1055 } 1075 }
1056 var result = _ops.lock(LOCK_UNLOCK, start, end); 1076 var result = _ops.lock(LOCK_UNLOCK, start, end);
1057 if (result is OSError) { 1077 if (result is OSError) {
1058 throw new FileSystemException('unlock failed', path, result); 1078 throw new FileSystemException('unlock failed', path, result);
1059 } 1079 }
1060 } 1080 }
1061 1081
1082 _FileTranslation get translation => _translation;
1083
1084 void set translation(_FileTranslation translation) {
1085 if (_translation != translation) {
1086 _ops.setTranslation(translation.index);
1087 _translation = translation;
1088 }
1089 }
1090
1062 bool closed = false; 1091 bool closed = false;
1063 1092
1064 // Calling this function will increase the reference count on the native 1093 // Calling this function will increase the reference count on the native
1065 // object that implements the file operations. It should only be called to 1094 // object that implements the file operations. It should only be called to
1066 // pass the pointer to the IO Service, which will decrement the reference 1095 // pass the pointer to the IO Service, which will decrement the reference
1067 // count when it is finished with it. 1096 // count when it is finished with it.
1068 int _pointer() => _ops.getPointer(); 1097 int _pointer() => _ops.getPointer();
1069 1098
1070 Future _dispatch(int request, List data, { bool markClosed: false }) { 1099 Future _dispatch(int request, List data, { bool markClosed: false }) {
1071 if (closed) { 1100 if (closed) {
(...skipping 19 matching lines...) Expand all
1091 void _checkAvailable() { 1120 void _checkAvailable() {
1092 if (_asyncDispatched) { 1121 if (_asyncDispatched) {
1093 throw new FileSystemException("An async operation is currently pending", 1122 throw new FileSystemException("An async operation is currently pending",
1094 path); 1123 path);
1095 } 1124 }
1096 if (closed) { 1125 if (closed) {
1097 throw new FileSystemException("File closed", path); 1126 throw new FileSystemException("File closed", path);
1098 } 1127 }
1099 } 1128 }
1100 } 1129 }
OLDNEW
« no previous file with comments | « runtime/bin/utils_win.h ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698