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 * Returns whether a directory with this name already exists. |
15 */ | 15 */ |
16 bool existsSync(); | 16 bool existsSync(); |
17 | 17 |
18 /** | 18 /** |
19 * Creates the directory with this name if it does not exist. | 19 * Creates the directory with this name if it does not exist. |
20 * Throw an exception if the directory already exists. | 20 * Throw an exception if the directory already exists. |
21 */ | 21 */ |
22 void createSync(); | 22 void createSync(); |
23 | 23 |
24 /** | 24 /** |
25 * 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 | |
27 * 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 | |
29 * are used for the template. | |
30 * 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 | |
32 * createTempHandler will be called. The error handler is called if | |
33 * the temporary directory cannot be created. | |
34 */ | |
35 void createTemp(); | |
36 | |
37 /** | |
25 * Deletes the directory with this name. Throws an exception | 38 * Deletes the directory with this name. Throws an exception |
26 * if the directory is not empty or if deletion failed. | 39 * if the directory is not empty or if deletion failed. |
27 */ | 40 */ |
28 void deleteSync(); | 41 void deleteSync(); |
29 | 42 |
30 /** | 43 /** |
31 * List the sub-directories and files of this | 44 * List the sub-directories and files of this |
32 * [Directory]. Optionally recurse into sub-directories. For each | 45 * [Directory]. Optionally recurse into sub-directories. For each |
33 * file and directory, the file or directory handler is called. When | 46 * file and directory, the file or directory handler is called. When |
34 * all directories have been listed the done handler is called. If | 47 * all directories have been listed the done handler is called. If |
(...skipping 17 matching lines...) Expand all Loading... | |
52 void set fileHandler(void fileHandler(String file)); | 65 void set fileHandler(void fileHandler(String file)); |
53 | 66 |
54 /** | 67 /** |
55 * Set the handler that is called when a directory listing is | 68 * Set the handler that is called when a directory listing is |
56 * done. The handler is called with an indication of whether or not | 69 * done. The handler is called with an indication of whether or not |
57 * the listing operation completed. | 70 * the listing operation completed. |
58 */ | 71 */ |
59 void set doneHandler(void doneHandler(bool completed)); | 72 void set doneHandler(void doneHandler(bool completed)); |
60 | 73 |
61 /** | 74 /** |
62 * Sets the handler that is called on error listing directories. | 75 * Set the handler that is called when a temporary directory is created. |
Mads Ager (google)
2011/11/21 16:29:37
Maybe shorten this to just state that it is called
Bill Hesse
2011/11/22 12:49:39
Done.
| |
76 * The handler is called when the directory creation is completed. | |
77 * The error handler is called if the directory creation fails. | |
78 */ | |
79 void set createTempHandler(void doneHandler(bool completed)); | |
80 | |
81 /** | |
82 * Sets the handler that is called if there is an error while listing | |
83 * or creating directories. | |
63 */ | 84 */ |
64 void set errorHandler(void errorHandler(String error)); | 85 void set errorHandler(void errorHandler(String error)); |
65 | 86 |
66 /** | 87 /** |
67 * Gets the path of this directory. | 88 * Gets the path of this directory. |
68 */ | 89 */ |
69 final String path; | 90 final String path; |
70 } | 91 } |
71 | 92 |
72 | 93 |
73 class DirectoryException { | 94 class DirectoryException { |
74 const DirectoryException(String this.message); | 95 const DirectoryException(String this.message); |
75 String toString() => "DirectoryException: $message"; | 96 String toString() => "DirectoryException: $message"; |
76 final String message; | 97 final String message; |
77 } | 98 } |
OLD | NEW |