Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface Directory factory _Directory { | 5 interface Directory factory _Directory { |
| 6 /** | 6 /** |
| 7 * Creates a directory object. The path is either a full path or | 7 * Creates a directory object. The path is either a full path or |
| 8 * relative to the directory in which the Dart VM was | 8 * relative to the directory in which the Dart VM was |
| 9 * started. | 9 * started. |
| 10 */ | 10 */ |
| 11 Directory(String path); | 11 Directory(String path); |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Returns whether a directory with this name already exists. | 14 * Check whether a directory with this name already exists. If the |
| 15 * operation completes successfully the [existsHandler] is called with | |
| 16 * the result. Otherwise the [errorHandler] is called. | |
| 17 */ | |
| 18 void exists(); | |
| 19 | |
| 20 /** | |
| 21 * Synchronously check whether a directory with this name already exists. | |
| 15 */ | 22 */ |
| 16 bool existsSync(); | 23 bool existsSync(); |
| 17 | 24 |
| 18 /** | 25 /** |
| 19 * Creates the directory with this name if it does not exist. | 26 * Creates the directory with this name if it does not exist. |
| 20 * Throw an exception if the directory already exists. | 27 * If the directory is successfully created the [createHandler] is |
| 28 * called. Otherwise the [errorHandler] is called. | |
| 29 */ | |
| 30 void create(); | |
| 31 | |
| 32 /** | |
| 33 * Synchronously creates the directory with this name if it does not exist. | |
| 34 * Throws an exception if the directory already exists. | |
| 21 */ | 35 */ |
| 22 void createSync(); | 36 void createSync(); |
| 23 | 37 |
| 24 /** | 38 /** |
| 25 * Creates a temporary directory with a name based on the current path. | 39 * Creates a temporary directory with a name based on the current path. |
| 26 * This name and path is used as a template, and additional characters are | 40 * This name and path is used as a template, and additional characters are |
| 27 * appended to it by the call to make a unique directory name. If the | 41 * appended to it by the call to make a unique directory name. If the |
| 28 * path is the empty string, a default system temp directory and name | 42 * path is the empty string, a default system temp directory and name |
| 29 * are used for the template. | 43 * are used for the template. |
| 30 * The path is modified to be the path of the new directory. | 44 * The path is modified to be the path of the new directory. |
| 31 * After the new directory is created, and the path modified, the callback | 45 * After the new directory is created, and the path modified, the callback |
| 32 * createTempHandler will be called. The error handler is called if | 46 * createTempHandler will be called. The error handler is called if |
| 33 * the temporary directory cannot be created. | 47 * the temporary directory cannot be created. |
| 34 */ | 48 */ |
| 35 void createTemp(); | 49 void createTemp(); |
| 36 | 50 |
| 37 /** | 51 /** |
| 38 * Synchronously creates a temporary directory with a name based on the curren t path. | 52 * Synchronously creates a temporary directory with a name based on the curren t path. |
|
Søren Gjesse
2011/12/20 09:12:40
Long line.
Mads Ager (google)
2011/12/20 09:26:24
Done.
| |
| 39 * This name and path is used as a template, and additional characters are | 53 * This name and path is used as a template, and additional characters are |
| 40 * appended to it by the call to make a unique directory name. If the | 54 * appended to it by the call to make a unique directory name. If the |
| 41 * path is the empty string, a default system temp directory and name | 55 * path is the empty string, a default system temp directory and name |
| 42 * are used for the template. | 56 * are used for the template. |
| 43 * The path is modified to be the path of the new directory. | 57 * The path is modified to be the path of the new directory. |
| 44 */ | 58 */ |
| 45 void createTempSync(); | 59 void createTempSync(); |
| 46 | 60 |
| 47 /** | 61 /** |
| 62 * Deletes the directory with this name. If the operation completes | |
| 63 * successfully the [deleteHandler] is called. Otherwise the | |
| 64 * [errorHandler] is called. | |
| 65 */ | |
| 66 void delete(); | |
| 67 | |
| 68 /** | |
| 48 * Deletes the directory with this name. Throws an exception | 69 * Deletes the directory with this name. Throws an exception |
| 49 * if the directory is not empty or if deletion failed. | 70 * if the directory is not empty or if deletion failed. |
| 50 */ | 71 */ |
| 51 void deleteSync(); | 72 void deleteSync(); |
| 52 | 73 |
| 53 /** | 74 /** |
| 54 * List the sub-directories and files of this | 75 * List the sub-directories and files of this |
| 55 * [Directory]. Optionally recurse into sub-directories. For each | 76 * [Directory]. Optionally recurse into sub-directories. For each |
| 56 * file and directory, the file or directory handler is called. When | 77 * file and directory, the file or directory handler is called. When |
| 57 * all directories have been listed the done handler is called. If | 78 * all directories have been listed the done handler is called. If |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 75 void set fileHandler(void fileHandler(String file)); | 96 void set fileHandler(void fileHandler(String file)); |
| 76 | 97 |
| 77 /** | 98 /** |
| 78 * Set the handler that is called when a directory listing is | 99 * Set the handler that is called when a directory listing is |
| 79 * done. The handler is called with an indication of whether or not | 100 * done. The handler is called with an indication of whether or not |
| 80 * the listing operation completed. | 101 * the listing operation completed. |
| 81 */ | 102 */ |
| 82 void set doneHandler(void doneHandler(bool completed)); | 103 void set doneHandler(void doneHandler(bool completed)); |
| 83 | 104 |
| 84 /** | 105 /** |
| 106 * Set the handler that is called when checking if a directory with this | |
| 107 * name exists. | |
| 108 */ | |
| 109 void set existsHandler(void existsHandler(bool exists)); | |
| 110 | |
| 111 /** | |
| 112 * Set the handler that is called when a directory is successfully created. | |
| 113 */ | |
| 114 void set createHandler(void createHandler()); | |
| 115 | |
| 116 /** | |
| 85 * Set the handler that is called when a temporary directory is | 117 * Set the handler that is called when a temporary directory is |
| 86 * successfully created. | 118 * successfully created. |
| 87 */ | 119 */ |
| 88 void set createTempHandler(void doneHandler(bool completed)); | 120 void set createTempHandler(void doneHandler(bool completed)); |
| 89 | 121 |
| 90 /** | 122 /** |
| 123 * Set the handler that is called when a directory is successfully | |
| 124 * deleted. | |
| 125 */ | |
| 126 void set deleteHandler(void deleteHandler()); | |
| 127 | |
| 128 /** | |
| 91 * Sets the handler that is called if there is an error while listing | 129 * Sets the handler that is called if there is an error while listing |
| 92 * or creating directories. | 130 * or creating directories. |
| 93 */ | 131 */ |
| 94 void set errorHandler(void errorHandler(String error)); | 132 void set errorHandler(void errorHandler(String error)); |
| 95 | 133 |
| 96 /** | 134 /** |
| 97 * Gets the path of this directory. | 135 * Gets the path of this directory. |
| 98 */ | 136 */ |
| 99 final String path; | 137 final String path; |
| 100 } | 138 } |
| 101 | 139 |
| 102 | 140 |
| 103 class DirectoryException { | 141 class DirectoryException { |
| 104 const DirectoryException([String this.message, int this.errorCode = 0]); | 142 const DirectoryException([String this.message, int this.errorCode = 0]); |
| 105 String toString() => "DirectoryException: $message"; | 143 String toString() => "DirectoryException: $message"; |
| 106 final String message; | 144 final String message; |
| 107 final int errorCode; | 145 final int errorCode; |
| 108 } | 146 } |
| OLD | NEW |