OLD | NEW |
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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _Directory implements Directory { | 7 class _Directory implements Directory { |
8 static const CREATE_REQUEST = 0; | 8 static const CREATE_REQUEST = 0; |
9 static const DELETE_REQUEST = 1; | 9 static const DELETE_REQUEST = 1; |
10 static const EXISTS_REQUEST = 2; | 10 static const EXISTS_REQUEST = 2; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 if (_path is !String) { | 54 if (_path is !String) { |
55 throw new ArgumentError(); | 55 throw new ArgumentError(); |
56 } | 56 } |
57 var result = _exists(_path); | 57 var result = _exists(_path); |
58 if (result is OSError) { | 58 if (result is OSError) { |
59 throw new DirectoryIOException("Exists failed", _path, result); | 59 throw new DirectoryIOException("Exists failed", _path, result); |
60 } | 60 } |
61 return (result == 1); | 61 return (result == 1); |
62 } | 62 } |
63 | 63 |
| 64 Future<FileStat> stat() => FileStat.stat(path); |
| 65 |
| 66 FileStat statSync() => FileStat.statSync(path); |
| 67 |
64 // Compute the index of the first directory in the list that exists. If | 68 // Compute the index of the first directory in the list that exists. If |
65 // none of the directories exist dirsToCreate.length is returned. | 69 // none of the directories exist dirsToCreate.length is returned. |
66 Future<int> _computeExistingIndex(List dirsToCreate) { | 70 Future<int> _computeExistingIndex(List dirsToCreate) { |
67 var future; | 71 var future; |
68 var notFound = dirsToCreate.length; | 72 var notFound = dirsToCreate.length; |
69 for (var i = 0; i < dirsToCreate.length; i++) { | 73 for (var i = 0; i < dirsToCreate.length; i++) { |
70 if (future == null) { | 74 if (future == null) { |
71 future = dirsToCreate[i].exists().then((e) => e ? i : notFound); | 75 future = dirsToCreate[i].exists().then((e) => e ? i : notFound); |
72 } else { | 76 } else { |
73 future = future.then((index) { | 77 future = future.then((index) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 335 |
332 void _ensureDirectoryService() { | 336 void _ensureDirectoryService() { |
333 if (_directoryService == null) { | 337 if (_directoryService == null) { |
334 _directoryService = _newServicePort(); | 338 _directoryService = _newServicePort(); |
335 } | 339 } |
336 } | 340 } |
337 | 341 |
338 final String _path; | 342 final String _path; |
339 SendPort _directoryService; | 343 SendPort _directoryService; |
340 } | 344 } |
OLD | NEW |