| 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 asyncStart(); | 11 asyncStart(); |
| 12 | 12 |
| 13 // On MacOS you get the decomposed utf8 form of file and directory | 13 // On MacOS you get the decomposed utf8 form of file and directory |
| 14 // names from the system. Therefore, we have to check for both here. | 14 // names from the system. Therefore, we have to check for both here. |
| 15 var precomposed = 'æøå'; | 15 var precomposed = 'æøå'; |
| 16 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); | 16 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); |
| 17 | 17 |
| 18 new Directory('').createTemp().then((tempDir) { | 18 Directory.systemTemp.createTemp('dart_directory_non_ascii').then((tempDir) { |
| 19 var nonAsciiDir = new Directory("${tempDir.path}/æøå"); | 19 var nonAsciiDir = new Directory("${tempDir.path}/æøå"); |
| 20 nonAsciiDir.exists().then((e) { | 20 nonAsciiDir.exists() |
| 21 Expect.isFalse(e); | 21 .then((e) => Expect.isFalse(e)) |
| 22 nonAsciiDir.create().then((_) { | 22 .then((_) => nonAsciiDir.create()) |
| 23 nonAsciiDir.exists().then((e) { | 23 .then((_) => nonAsciiDir.exists()) |
| 24 Expect.isTrue(e); | 24 .then((e) => Expect.isTrue(e)) |
| 25 new Directory("${tempDir.path}/æøå").createTemp().then((temp) { | 25 .then((_) => new Directory("${tempDir.path}/æøå").createTemp('temp')) |
| 26 Expect.isTrue(temp.path.contains(precomposed) || | 26 .then((temp) { |
| 27 temp.path.contains(decomposed)); | 27 Expect.isTrue(temp.path.contains(precomposed) || |
| 28 temp.delete().then((_) { | 28 temp.path.contains(decomposed)); |
| 29 tempDir.delete(recursive: true).then((_) { | 29 return temp.delete(); |
| 30 Expect.isFalse(temp.existsSync()); | 30 }).then((_) => tempDir.createTemp('æøå')) |
| 31 Expect.isFalse(nonAsciiDir.existsSync()); | 31 .then((temp) { |
| 32 asyncEnd(); | 32 Expect.isTrue(temp.path.contains(precomposed) || |
| 33 }); | 33 temp.path.contains(decomposed)); |
| 34 }); | 34 return temp.delete(); |
| 35 }); | 35 }).then((temp) => Expect.isFalse(temp.existsSync())) |
| 36 .then((_) => tempDir.delete(recursive: true)) |
| 37 .then((_) { |
| 38 Expect.isFalse(nonAsciiDir.existsSync()); |
| 39 asyncEnd(); |
| 36 }); | 40 }); |
| 37 }); | |
| 38 }); | |
| 39 }); | 41 }); |
| 40 } | 42 } |
| OLD | NEW |