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 // Directory listing test. | 5 // Directory listing test. |
6 | 6 |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 import "dart:isolate"; | 9 import "dart:isolate"; |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 }); | 117 }); |
118 } | 118 } |
119 }); | 119 }); |
120 } | 120 } |
121 var subDirName = 'subdir'; | 121 var subDirName = 'subdir'; |
122 var subDir = new Directory("${d.path}/$subDirName"); | 122 var subDir = new Directory("${d.path}/$subDirName"); |
123 subDir.create().then((ignore) { | 123 subDir.create().then((ignore) { |
124 // Construct a long string of the form | 124 // Construct a long string of the form |
125 // 'tempdir/subdir/../subdir/../subdir'. | 125 // 'tempdir/subdir/../subdir/../subdir'. |
126 var buffer = new StringBuffer(); | 126 var buffer = new StringBuffer(); |
127 buffer.add(subDir.path); | 127 buffer.write(subDir.path); |
128 for (var i = 0; i < 1000; i++) { | 128 for (var i = 0; i < 1000; i++) { |
129 buffer.add("/../${subDirName}"); | 129 buffer.write("/../${subDirName}"); |
130 } | 130 } |
131 var long = new Directory("${buffer.toString()}"); | 131 var long = new Directory("${buffer.toString()}"); |
132 setupListHandlers(long.list()); | 132 setupListHandlers(long.list()); |
133 setupListHandlers(long.list(recursive: true)); | 133 setupListHandlers(long.list(recursive: true)); |
134 }); | 134 }); |
135 }); | 135 }); |
136 } | 136 } |
137 | 137 |
138 static void testDeleteNonExistent() { | 138 static void testDeleteNonExistent() { |
139 // Test that deleting a non-existing directory fails. | 139 // Test that deleting a non-existing directory fails. |
(...skipping 15 matching lines...) Expand all Loading... |
155 | 155 |
156 static void testDeleteTooLongName() { | 156 static void testDeleteTooLongName() { |
157 var port = new ReceivePort(); | 157 var port = new ReceivePort(); |
158 new Directory("").createTemp().then((d) { | 158 new Directory("").createTemp().then((d) { |
159 var subDirName = 'subdir'; | 159 var subDirName = 'subdir'; |
160 var subDir = new Directory("${d.path}/$subDirName"); | 160 var subDir = new Directory("${d.path}/$subDirName"); |
161 subDir.create().then((ignore) { | 161 subDir.create().then((ignore) { |
162 // Construct a long string of the form | 162 // Construct a long string of the form |
163 // 'tempdir/subdir/../subdir/../subdir'. | 163 // 'tempdir/subdir/../subdir/../subdir'. |
164 var buffer = new StringBuffer(); | 164 var buffer = new StringBuffer(); |
165 buffer.add(subDir.path); | 165 buffer.write(subDir.path); |
166 for (var i = 0; i < 1000; i++) { | 166 for (var i = 0; i < 1000; i++) { |
167 buffer.add("/../${subDirName}"); | 167 buffer.write("/../${subDirName}"); |
168 } | 168 } |
169 var long = new Directory("${buffer.toString()}"); | 169 var long = new Directory("${buffer.toString()}"); |
170 var errors = 0; | 170 var errors = 0; |
171 onError(e) { | 171 onError(e) { |
172 Expect.isTrue(e.error is DirectoryIOException); | 172 Expect.isTrue(e.error is DirectoryIOException); |
173 if (++errors == 2) { | 173 if (++errors == 2) { |
174 d.delete(recursive: true).then((ignore) => port.close()); | 174 d.delete(recursive: true).then((ignore) => port.close()); |
175 } | 175 } |
176 return true; | 176 return true; |
177 } | 177 } |
(...skipping 11 matching lines...) Expand all Loading... |
189 } | 189 } |
190 | 190 |
191 static void testDeleteTooLongNameSync() { | 191 static void testDeleteTooLongNameSync() { |
192 Directory d = new Directory("").createTempSync(); | 192 Directory d = new Directory("").createTempSync(); |
193 var subDirName = 'subdir'; | 193 var subDirName = 'subdir'; |
194 var subDir = new Directory("${d.path}/$subDirName"); | 194 var subDir = new Directory("${d.path}/$subDirName"); |
195 subDir.createSync(); | 195 subDir.createSync(); |
196 // Construct a long string of the form | 196 // Construct a long string of the form |
197 // 'tempdir/subdir/../subdir/../subdir'. | 197 // 'tempdir/subdir/../subdir/../subdir'. |
198 var buffer = new StringBuffer(); | 198 var buffer = new StringBuffer(); |
199 buffer.add(subDir.path); | 199 buffer.write(subDir.path); |
200 for (var i = 0; i < 1000; i++) { | 200 for (var i = 0; i < 1000; i++) { |
201 buffer.add("/../${subDirName}"); | 201 buffer.write("/../${subDirName}"); |
202 } | 202 } |
203 var long = new Directory("${buffer.toString()}"); | 203 var long = new Directory("${buffer.toString()}"); |
204 Expect.throws(long.deleteSync); | 204 Expect.throws(long.deleteSync); |
205 Expect.throws(() => long.deleteSync(recursive: true)); | 205 Expect.throws(() => long.deleteSync(recursive: true)); |
206 d.deleteSync(recursive: true); | 206 d.deleteSync(recursive: true); |
207 } | 207 } |
208 | 208 |
209 static void testExistsCreateDelete() { | 209 static void testExistsCreateDelete() { |
210 new Directory("").createTemp().then((d) { | 210 new Directory("").createTemp().then((d) { |
211 d.exists().then((bool exists) { | 211 d.exists().then((bool exists) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 testCreateTempErrorSync(); | 519 testCreateTempErrorSync(); |
520 testCreateTempError(); | 520 testCreateTempError(); |
521 testCreateExistingSync(); | 521 testCreateExistingSync(); |
522 testCreateExisting(); | 522 testCreateExisting(); |
523 testCreateDirExistingFileSync(); | 523 testCreateDirExistingFileSync(); |
524 testCreateDirExistingFile(); | 524 testCreateDirExistingFile(); |
525 testCreateRecursive(); | 525 testCreateRecursive(); |
526 testCreateRecursiveSync(); | 526 testCreateRecursiveSync(); |
527 testRename(); | 527 testRename(); |
528 } | 528 } |
OLD | NEW |