| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 if (future == null) { | 93 if (future == null) { |
| 94 return new Future.value(notFound); | 94 return new Future.value(notFound); |
| 95 } else { | 95 } else { |
| 96 return future; | 96 return future; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 Future<Directory> createRecursively() { | 100 Future<Directory> createRecursively() { |
| 101 var path = new Path(path); | 101 var path = new Path(this.path); |
| 102 var dirsToCreate = []; | 102 var dirsToCreate = []; |
| 103 var terminator = path.isAbsolute ? '/' : ''; | 103 var terminator = path.isAbsolute ? '/' : ''; |
| 104 while (path.toString() != terminator) { | 104 while (path.toString() != terminator) { |
| 105 dirsToCreate.add(new Directory.fromPath(path)); | 105 dirsToCreate.add(new Directory.fromPath(path)); |
| 106 path = path.directoryPath; | 106 path = path.directoryPath; |
| 107 } | 107 } |
| 108 return _computeExistingIndex(dirsToCreate).then((index) { | 108 return _computeExistingIndex(dirsToCreate).then((index) { |
| 109 var future; | 109 var future; |
| 110 for (var i = index - 1; i >= 0 ; i--) { | 110 for (var i = index - 1; i >= 0 ; i--) { |
| 111 if (future == null) { | 111 if (future == null) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 132 request[1] = path; | 132 request[1] = path; |
| 133 return _directoryService.call(request).then((response) { | 133 return _directoryService.call(request).then((response) { |
| 134 if (_isErrorResponse(response)) { | 134 if (_isErrorResponse(response)) { |
| 135 throw _exceptionOrErrorFromResponse(response, "Creation failed"); | 135 throw _exceptionOrErrorFromResponse(response, "Creation failed"); |
| 136 } | 136 } |
| 137 return this; | 137 return this; |
| 138 }); | 138 }); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void createRecursivelySync() { | 141 void createRecursivelySync() { |
| 142 var path = new Path(path); | 142 var path = new Path(this.path); |
| 143 var dirsToCreate = []; | 143 var dirsToCreate = []; |
| 144 var terminator = path.isAbsolute ? '/' : ''; | 144 var terminator = path.isAbsolute ? '/' : ''; |
| 145 while (path.toString() != terminator) { | 145 while (path.toString() != terminator) { |
| 146 var dir = new Directory.fromPath(path); | 146 var dir = new Directory.fromPath(path); |
| 147 if (dir.existsSync()) break; | 147 if (dir.existsSync()) break; |
| 148 dirsToCreate.add(dir); | 148 dirsToCreate.add(dir); |
| 149 path = path.directoryPath; | 149 path = path.directoryPath; |
| 150 } | 150 } |
| 151 for (var i = dirsToCreate.length - 1; i >= 0; i--) { | 151 for (var i = dirsToCreate.length - 1; i >= 0; i--) { |
| 152 dirsToCreate[i].createSync(); | 152 dirsToCreate[i].createSync(); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 controller.addError( | 414 controller.addError( |
| 415 new DirectoryException("Directory listing failed", | 415 new DirectoryException("Directory listing failed", |
| 416 errorPath, | 416 errorPath, |
| 417 err)); | 417 err)); |
| 418 } else { | 418 } else { |
| 419 controller.addError( | 419 controller.addError( |
| 420 new DirectoryException("Internal error")); | 420 new DirectoryException("Internal error")); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 } | 423 } |
| OLD | NEW |