OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.file_system.physical_file_system; | 5 library analyzer.file_system.physical_file_system; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:core'; | 8 import 'dart:core'; |
9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 */ | 45 */ |
46 const String _SERVER_DIR = ".dartServer"; | 46 const String _SERVER_DIR = ".dartServer"; |
47 | 47 |
48 /** | 48 /** |
49 * Returns the path to the user's home directory. | 49 * Returns the path to the user's home directory. |
50 */ | 50 */ |
51 String _getStandardStateLocation() { | 51 String _getStandardStateLocation() { |
52 final home = io.Platform.isWindows | 52 final home = io.Platform.isWindows |
53 ? io.Platform.environment['LOCALAPPDATA'] | 53 ? io.Platform.environment['LOCALAPPDATA'] |
54 : io.Platform.environment['HOME']; | 54 : io.Platform.environment['HOME']; |
55 return io.FileSystemEntity.isDirectorySync(home) | 55 return home != null && io.FileSystemEntity.isDirectorySync(home) |
56 ? join(home, _SERVER_DIR) | 56 ? join(home, _SERVER_DIR) |
57 : null; | 57 : null; |
58 } | 58 } |
59 | 59 |
60 /** | 60 /** |
61 * A `dart:io` based implementation of [ResourceProvider]. | 61 * A `dart:io` based implementation of [ResourceProvider]. |
62 */ | 62 */ |
63 class PhysicalResourceProvider implements ResourceProvider { | 63 class PhysicalResourceProvider implements ResourceProvider { |
64 static final FileReadMode NORMALIZE_EOL_ALWAYS = | 64 static final FileReadMode NORMALIZE_EOL_ALWAYS = |
65 (String string) => string.replaceAll(new RegExp('\r\n?'), '\n'); | 65 (String string) => string.replaceAll(new RegExp('\r\n?'), '\n'); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 timer.cancel(); | 449 timer.cancel(); |
450 } | 450 } |
451 }); | 451 }); |
452 return completer.future; | 452 return completer.future; |
453 } | 453 } |
454 _isSpawning = true; | 454 _isSpawning = true; |
455 _runner = await IsolateRunner.spawn(); | 455 _runner = await IsolateRunner.spawn(); |
456 return _runner; | 456 return _runner; |
457 } | 457 } |
458 } | 458 } |
OLD | NEW |