| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 */ | 72 */ |
| 73 static Future<FileStat> stat(String path) { | 73 static Future<FileStat> stat(String path) { |
| 74 // Get a new file service port for each request. We could also cache one. | 74 // Get a new file service port for each request. We could also cache one. |
| 75 var service = _FileUtils._newServicePort(); | 75 var service = _FileUtils._newServicePort(); |
| 76 List request = new List(2); | 76 List request = new List(2); |
| 77 request[0] = _STAT_REQUEST; | 77 request[0] = _STAT_REQUEST; |
| 78 request[1] = path; | 78 request[1] = path; |
| 79 return service.call(request).then((response) { | 79 return service.call(request).then((response) { |
| 80 if (_isErrorResponse(response)) { | 80 if (_isErrorResponse(response)) { |
| 81 throw _exceptionFromResponse(response, | 81 throw _exceptionFromResponse(response, |
| 82 "Error getting stat of '$path'"); | 82 "Error getting stat", |
| 83 path); |
| 83 } | 84 } |
| 84 // Unwrap the real list from the "I'm not an error" wrapper. | 85 // Unwrap the real list from the "I'm not an error" wrapper. |
| 85 List data = response[1]; | 86 List data = response[1]; |
| 86 return new FileStat._internal( | 87 return new FileStat._internal( |
| 87 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), | 88 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), |
| 88 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000), | 89 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000), |
| 89 new DateTime.fromMillisecondsSinceEpoch(data[_ACCESSED_TIME] * 1000), | 90 new DateTime.fromMillisecondsSinceEpoch(data[_ACCESSED_TIME] * 1000), |
| 90 FileSystemEntityType._lookup(data[_TYPE]), | 91 FileSystemEntityType._lookup(data[_TYPE]), |
| 91 data[_MODE], | 92 data[_MODE], |
| 92 data[_SIZE]); | 93 data[_SIZE]); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 179 |
| 179 static Future<int> _getTypeAsync(String path, bool followLinks) { | 180 static Future<int> _getTypeAsync(String path, bool followLinks) { |
| 180 // Get a new file service port for each request. We could also cache one. | 181 // Get a new file service port for each request. We could also cache one. |
| 181 var service = _FileUtils._newServicePort(); | 182 var service = _FileUtils._newServicePort(); |
| 182 List request = new List(3); | 183 List request = new List(3); |
| 183 request[0] = _TYPE_REQUEST; | 184 request[0] = _TYPE_REQUEST; |
| 184 request[1] = path; | 185 request[1] = path; |
| 185 request[2] = followLinks; | 186 request[2] = followLinks; |
| 186 return service.call(request).then((response) { | 187 return service.call(request).then((response) { |
| 187 if (_isErrorResponse(response)) { | 188 if (_isErrorResponse(response)) { |
| 188 throw _exceptionFromResponse(response, | 189 throw _exceptionFromResponse(response, "Error getting type", path); |
| 189 "Error getting type of '$path'"); | |
| 190 } | 190 } |
| 191 return response; | 191 return response; |
| 192 }); | 192 }); |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * Synchronously checks whether two paths refer to the same object in the | 196 * Synchronously checks whether two paths refer to the same object in the |
| 197 * file system. Returns a [:Future<bool>:] that completes with the result. | 197 * file system. Returns a [:Future<bool>:] that completes with the result. |
| 198 * | 198 * |
| 199 * Comparing a link to its target returns false, as does comparing two links | 199 * Comparing a link to its target returns false, as does comparing two links |
| 200 * that point to the same target. To check the target of a link, use | 200 * that point to the same target. To check the target of a link, use |
| 201 * Link.target explicitly to fetch it. Directory links appearing | 201 * Link.target explicitly to fetch it. Directory links appearing |
| 202 * inside a path are followed, though, to find the file system object. | 202 * inside a path are followed, though, to find the file system object. |
| 203 * | 203 * |
| 204 * Completes the returned Future with an error if one of the paths points | 204 * Completes the returned Future with an error if one of the paths points |
| 205 * to an object that does not exist. | 205 * to an object that does not exist. |
| 206 */ | 206 */ |
| 207 static Future<bool> identical(String path1, String path2) { | 207 static Future<bool> identical(String path1, String path2) { |
| 208 // Get a new file service port for each request. We could also cache one. | 208 // Get a new file service port for each request. We could also cache one. |
| 209 var service = _FileUtils._newServicePort(); | 209 var service = _FileUtils._newServicePort(); |
| 210 List request = new List(3); | 210 List request = new List(3); |
| 211 request[0] = _IDENTICAL_REQUEST; | 211 request[0] = _IDENTICAL_REQUEST; |
| 212 request[1] = path1; | 212 request[1] = path1; |
| 213 request[2] = path2; | 213 request[2] = path2; |
| 214 return service.call(request).then((response) { | 214 return service.call(request).then((response) { |
| 215 if (_isErrorResponse(response)) { | 215 if (_isErrorResponse(response)) { |
| 216 throw _exceptionFromResponse(response, | 216 throw _exceptionFromResponse(response, |
| 217 "Error in FileSystemEntity.identical($path1, $path2)"); | 217 "Error in FileSystemEntity.identical($path1, $path2)", ""); |
| 218 } | 218 } |
| 219 return response; | 219 return response; |
| 220 }); | 220 }); |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 /** | 224 /** |
| 225 * Synchronously checks whether two paths refer to the same object in the | 225 * Synchronously checks whether two paths refer to the same object in the |
| 226 * file system. | 226 * file system. |
| 227 * | 227 * |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 391 |
| 392 | 392 |
| 393 static _throwIfError(Object result, String msg) { | 393 static _throwIfError(Object result, String msg) { |
| 394 if (result is OSError) { | 394 if (result is OSError) { |
| 395 throw new FileException(msg, result); | 395 throw new FileException(msg, result); |
| 396 } else if (result is ArgumentError) { | 396 } else if (result is ArgumentError) { |
| 397 throw result; | 397 throw result; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 } | 400 } |
| OLD | NEW |