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 /** | 7 /** |
8 * [Directory] objects are used for working with directories. | 8 * [Directory] objects are used for working with directories. |
9 */ | 9 */ |
10 abstract class Directory extends FileSystemEntity { | 10 abstract class Directory extends FileSystemEntity { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 * current path. The path is used as a template, and additional | 80 * current path. The path is used as a template, and additional |
81 * characters are appended to it to make a unique temporary directory name. | 81 * characters are appended to it to make a unique temporary directory name. |
82 * If the path is the empty string, a default system temp directory and name | 82 * If the path is the empty string, a default system temp directory and name |
83 * are used for the template. Returns the newly created temporary directory. | 83 * are used for the template. Returns the newly created temporary directory. |
84 */ | 84 */ |
85 Directory createTempSync(); | 85 Directory createTempSync(); |
86 | 86 |
87 /** | 87 /** |
88 * Deletes this directory. | 88 * Deletes this directory. |
89 * | 89 * |
90 * If [recursive] is false, the directory must be empty. | 90 * If [recursive] is false, the directory must be empty. Only directories |
| 91 * and links to directories will be deleted. |
91 * | 92 * |
92 * If [recursive] is true, this directory and all sub-directories | 93 * If [recursive] is true, this directory and all sub-directories |
93 * and files in the directories are deleted. | 94 * and files in the directories are deleted. Links are not followed |
| 95 * when deleting recursively. Only the link is deleted, not its target. |
| 96 * |
| 97 * If [recursive] is true, the target is deleted even if it is a file, or |
| 98 * a link to a file, not only if it is a directory. This behavior allows |
| 99 * [delete] to be used to unconditionally delete any file system object. |
94 * | 100 * |
95 * Returns a [:Future<Directory>:] that completes with this | 101 * Returns a [:Future<Directory>:] that completes with this |
96 * directory when the deletion is done. If the directory cannot be | 102 * directory when the deletion is done. If the directory cannot be |
97 * deleted, the future completes with an exception. | 103 * deleted, the future completes with an exception. |
98 */ | 104 */ |
99 Future<Directory> delete({recursive: false}); | 105 Future<Directory> delete({recursive: false}); |
100 | 106 |
101 /** | 107 /** |
102 * Synchronously deletes this directory. | 108 * Synchronously deletes this directory. |
103 * | 109 * |
104 * If [recursive] is false, the directory must be empty. | 110 * If [recursive] is false, the directory must be empty. |
105 * | 111 * |
106 * If [recursive] is true, this directory and all sub-directories | 112 * If [recursive] is true, this directory and all sub-directories |
107 * and files in the directories are deleted. | 113 * and files in the directories are deleted. Links are not followed |
| 114 * when deleting recursively. Only the link is deleted, not its target. |
| 115 * |
| 116 * If [recursive] is true, the target is deleted even if it is a file, or |
| 117 * a link to a file, not only if it is a directory. This behavior allows |
| 118 * [delete] to be used to unconditionally delete any file system object. |
108 * | 119 * |
109 * Throws an exception if the directory cannot be deleted. | 120 * Throws an exception if the directory cannot be deleted. |
110 */ | 121 */ |
111 void deleteSync({recursive: false}); | 122 void deleteSync({recursive: false}); |
112 | 123 |
113 /** | 124 /** |
114 * Renames this directory. Returns a [:Future<Directory>:] that completes | 125 * Renames this directory. Returns a [:Future<Directory>:] that completes |
115 * with a [Directory] instance for the renamed directory. | 126 * with a [Directory] instance for the renamed directory. |
116 * | 127 * |
117 * If newPath identifies an existing directory, that directory is | 128 * If newPath identifies an existing directory, that directory is |
(...skipping 10 matching lines...) Expand all Loading... |
128 * replaced. If newPath identifies an existing file the operation | 139 * replaced. If newPath identifies an existing file the operation |
129 * fails and an exception is thrown. | 140 * fails and an exception is thrown. |
130 */ | 141 */ |
131 Directory renameSync(String newPath); | 142 Directory renameSync(String newPath); |
132 | 143 |
133 /** | 144 /** |
134 * Lists the sub-directories and files of this [Directory]. | 145 * Lists the sub-directories and files of this [Directory]. |
135 * Optionally recurses into sub-directories. | 146 * Optionally recurses into sub-directories. |
136 * | 147 * |
137 * If [followLinks] is false, then any symbolic links found | 148 * If [followLinks] is false, then any symbolic links found |
138 * are reported as links, rather than as directories or files, | 149 * are reported as [Link] objects, rather than as directories or files, |
139 * and are not recursed into. | 150 * and are not recursed into. |
140 * | 151 * |
| 152 * If [followLinks] is true, then working links are reported as |
| 153 * directories or files, depending on |
| 154 * their type, and links to directories are recursed into. |
| 155 * Broken links are reported as [Link] objects, |
| 156 * |
141 * The result is a stream of [FileSystemEntity] objects | 157 * The result is a stream of [FileSystemEntity] objects |
142 * for the directories, files, and links. | 158 * for the directories, files, and links. |
143 */ | 159 */ |
144 Stream<FileSystemEntity> list({bool recursive: false, | 160 Stream<FileSystemEntity> list({bool recursive: false, |
145 bool followLinks: true}); | 161 bool followLinks: true}); |
146 | 162 |
147 /** | 163 /** |
148 * Lists the sub-directories and files of this [Directory]. | 164 * Lists the sub-directories and files of this [Directory]. |
149 * Optionally recurses into sub-directories. | 165 * Optionally recurses into sub-directories. |
150 * | 166 * |
151 * If [followLinks] is false, then any symbolic links found | 167 * If [followLinks] is false, then any symbolic links found |
152 * are reported as links, rather than as directories or files, | 168 * are reported as [Link] objects, rather than as directories or files, |
153 * and are not recursed into. | 169 * and are not recursed into. |
154 * | 170 * |
| 171 * If [followLinks] is true, then working links are reported as |
| 172 * directories or files, depending on |
| 173 * their type, and links to directories are recursed into. |
| 174 * Broken links are reported as [Link] objects, |
| 175 * |
155 * Returns a [List] containing [FileSystemEntity] objects for the | 176 * Returns a [List] containing [FileSystemEntity] objects for the |
156 * directories, files, and links. | 177 * directories, files, and links. |
157 */ | 178 */ |
158 List<FileSystemEntity> listSync({bool recursive: false, | 179 List<FileSystemEntity> listSync({bool recursive: false, |
159 bool followLinks: true}); | 180 bool followLinks: true}); |
160 | 181 |
161 /** | 182 /** |
162 * Returns a human readable string for this Directory instance. | 183 * Returns a human readable string for this Directory instance. |
163 */ | 184 */ |
164 String toString(); | 185 String toString(); |
(...skipping 25 matching lines...) Expand all Loading... |
190 if (path != null) { | 211 if (path != null) { |
191 sb.write(", path = $path"); | 212 sb.write(", path = $path"); |
192 } | 213 } |
193 } | 214 } |
194 return sb.toString(); | 215 return sb.toString(); |
195 } | 216 } |
196 final String message; | 217 final String message; |
197 final String path; | 218 final String path; |
198 final OSError osError; | 219 final OSError osError; |
199 } | 220 } |
OLD | NEW |