| 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 physical_file_system; | 5 library physical_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/java_io.dart'; | 10 import 'package:analyzer/src/generated/java_io.dart'; |
| 11 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
| 12 import 'package:path/path.dart'; | 12 import 'package:path/path.dart'; |
| 13 import 'package:watcher/watcher.dart'; | 13 import 'package:watcher/watcher.dart'; |
| 14 | 14 |
| 15 import 'file_system.dart'; | 15 import 'file_system.dart'; |
| 16 | 16 |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * A `dart:io` based implementation of [ResourceProvider]. | 19 * A `dart:io` based implementation of [ResourceProvider]. |
| 20 */ | 20 */ |
| 21 class PhysicalResourceProvider implements ResourceProvider { | 21 class PhysicalResourceProvider implements ResourceProvider { |
| 22 |
| 23 static final NORMALIZE_EOL_ALWAYS = |
| 24 (String string) => string.replaceAll(new RegExp('\r\n?'), '\n'); |
| 25 |
| 22 static final PhysicalResourceProvider INSTANCE = | 26 static final PhysicalResourceProvider INSTANCE = |
| 23 new PhysicalResourceProvider._(); | 27 new PhysicalResourceProvider(null); |
| 24 | 28 |
| 25 /** | 29 /** |
| 26 * The name of the directory containing plugin specific subfolders used to | 30 * The name of the directory containing plugin specific subfolders used to |
| 27 * store data across sessions. | 31 * store data across sessions. |
| 28 */ | 32 */ |
| 29 static final String SERVER_DIR = ".dartServer"; | 33 static final String SERVER_DIR = ".dartServer"; |
| 30 | 34 |
| 31 PhysicalResourceProvider._(); | 35 PhysicalResourceProvider(String fileReadMode(String s)) { |
| 36 if (fileReadMode != null) { |
| 37 FileBasedSource.fileReadMode = fileReadMode; |
| 38 } |
| 39 } |
| 32 | 40 |
| 33 @override | 41 @override |
| 34 Context get pathContext => io.Platform.isWindows ? windows : posix; | 42 Context get pathContext => io.Platform.isWindows ? windows : posix; |
| 35 | 43 |
| 36 @override | 44 @override |
| 37 Resource getResource(String path) { | 45 Resource getResource(String path) { |
| 38 if (io.FileSystemEntity.isDirectorySync(path)) { | 46 if (io.FileSystemEntity.isDirectorySync(path)) { |
| 39 io.Directory directory = new io.Directory(path); | 47 io.Directory directory = new io.Directory(path); |
| 40 return new _PhysicalFolder(directory); | 48 return new _PhysicalFolder(directory); |
| 41 } else { | 49 } else { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool operator ==(other) { | 179 bool operator ==(other) { |
| 172 if (runtimeType != other.runtimeType) { | 180 if (runtimeType != other.runtimeType) { |
| 173 return false; | 181 return false; |
| 174 } | 182 } |
| 175 return path == other.path; | 183 return path == other.path; |
| 176 } | 184 } |
| 177 | 185 |
| 178 @override | 186 @override |
| 179 String toString() => path; | 187 String toString() => path; |
| 180 } | 188 } |
| OLD | NEW |