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

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

Issue 131583003: Fix FileSystemEntity:stat to remove trailing slashes, on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « no previous file | no next file » | 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 class FileSystemEntityType { 7 class FileSystemEntityType {
8 static const FILE = const FileSystemEntityType._internal(0); 8 static const FILE = const FileSystemEntityType._internal(0);
9 static const DIRECTORY = const FileSystemEntityType._internal(1); 9 static const DIRECTORY = const FileSystemEntityType._internal(1);
10 static const LINK = const FileSystemEntityType._internal(2); 10 static const LINK = const FileSystemEntityType._internal(2);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 external static List<int> _statSync(String path); 76 external static List<int> _statSync(String path);
77 77
78 78
79 /** 79 /**
80 * Calls the operating system's stat() function on [path]. 80 * Calls the operating system's stat() function on [path].
81 * Returns a [FileStat] object containing the data returned by stat(). 81 * Returns a [FileStat] object containing the data returned by stat().
82 * If the call fails, returns a [FileStat] object with .type set to 82 * If the call fails, returns a [FileStat] object with .type set to
83 * FileSystemEntityType.NOT_FOUND and the other fields invalid. 83 * FileSystemEntityType.NOT_FOUND and the other fields invalid.
84 */ 84 */
85 static FileStat statSync(String path) { 85 static FileStat statSync(String path) {
86 // Trailing path is not supported on Windows.
87 if (Platform.isWindows) {
88 path = FileSystemEntity._trimTrailingPathSeparators(path);
89 }
86 var data = _statSync(path); 90 var data = _statSync(path);
87 if (data is Error) throw data; 91 if (data is OSError) throw data;
88 return new FileStat._internal( 92 return new FileStat._internal(
89 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), 93 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000),
90 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000), 94 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000),
91 new DateTime.fromMillisecondsSinceEpoch(data[_ACCESSED_TIME] * 1000), 95 new DateTime.fromMillisecondsSinceEpoch(data[_ACCESSED_TIME] * 1000),
92 FileSystemEntityType._lookup(data[_TYPE]), 96 FileSystemEntityType._lookup(data[_TYPE]),
93 data[_MODE], 97 data[_MODE],
94 data[_SIZE]); 98 data[_SIZE]);
95 } 99 }
96 100
97 /** 101 /**
98 * Asynchronously calls the operating system's stat() function on [path]. 102 * Asynchronously calls the operating system's stat() function on [path].
99 * Returns a Future which completes with a [FileStat] object containing 103 * Returns a Future which completes with a [FileStat] object containing
100 * the data returned by stat(). 104 * the data returned by stat().
101 * If the call fails, completes the future with a [FileStat] object with 105 * If the call fails, completes the future with a [FileStat] object with
102 * .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid. 106 * .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid.
103 */ 107 */
104 static Future<FileStat> stat(String path) { 108 static Future<FileStat> stat(String path) {
109 // Trailing path is not supported on Windows.
110 if (Platform.isWindows) {
111 path = FileSystemEntity._trimTrailingPathSeparators(path);
112 }
105 return _IOService.dispatch(_FILE_STAT, [path]).then((response) { 113 return _IOService.dispatch(_FILE_STAT, [path]).then((response) {
106 if (_isErrorResponse(response)) { 114 if (_isErrorResponse(response)) {
107 throw _exceptionFromResponse(response, 115 throw _exceptionFromResponse(response,
108 "Error getting stat", 116 "Error getting stat",
109 path); 117 path);
110 } 118 }
111 // Unwrap the real list from the "I'm not an error" wrapper. 119 // Unwrap the real list from the "I'm not an error" wrapper.
112 List data = response[1]; 120 List data = response[1];
113 return new FileStat._internal( 121 return new FileStat._internal(
114 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), 122 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000),
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 return buffer.toString(); 764 return buffer.toString();
757 } 765 }
758 } 766 }
759 767
760 768
761 class _FileSystemWatcher { 769 class _FileSystemWatcher {
762 external static Stream<FileSystemEvent> watch( 770 external static Stream<FileSystemEvent> watch(
763 String path, int events, bool recursive); 771 String path, int events, bool recursive);
764 external static bool get isSupported; 772 external static bool get isSupported;
765 } 773 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698