| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 path_source; | 5 library path_source; | 
| 6 | 6 | 
| 7 import 'dart:async'; | 7 import 'dart:async'; | 
| 8 import 'dart:io'; | 8 import 'dart:io'; | 
| 9 | 9 | 
| 10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26 | 26 | 
| 27   Future<Pubspec> describe(PackageId id) { | 27   Future<Pubspec> describe(PackageId id) { | 
| 28     return defer(() { | 28     return defer(() { | 
| 29       _validatePath(id.name, id.description); | 29       _validatePath(id.name, id.description); | 
| 30       return new Pubspec.load(id.name, id.description["path"], | 30       return new Pubspec.load(id.name, id.description["path"], | 
| 31           systemCache.sources); | 31           systemCache.sources); | 
| 32     }); | 32     }); | 
| 33   } | 33   } | 
| 34 | 34 | 
| 35   bool descriptionsEqual(description1, description2) { | 35   bool descriptionsEqual(description1, description2) { | 
| 36     // Compare real paths after normalizing and resolving symlinks. | 36     try { | 
| 37     var path1 = new File(description1["path"]).fullPathSync(); | 37       // Compare real paths after normalizing and resolving symlinks. | 
| 38     var path2 = new File(description2["path"]).fullPathSync(); | 38       var path1 = new File(description1["path"]).fullPathSync(); | 
| 39     return path1 == path2; | 39       var path2 = new File(description2["path"]).fullPathSync(); | 
|  | 40       return path1 == path2; | 
|  | 41     } on FileIOException catch (ex) { | 
|  | 42       // If either of the files couldn't be found, fall back to just comparing | 
|  | 43       // the normalized paths. | 
|  | 44       var path1 = path.normalize(path.absolute(description1["path"])); | 
|  | 45       var path2 = path.normalize(path.absolute(description2["path"])); | 
|  | 46       return path1 == path2; | 
|  | 47     } | 
| 40   } | 48   } | 
| 41 | 49 | 
| 42   Future<bool> install(PackageId id, String destination) { | 50   Future<bool> install(PackageId id, String destination) { | 
| 43     return defer(() { | 51     return defer(() { | 
| 44       try { | 52       try { | 
| 45         _validatePath(id.name, id.description); | 53         _validatePath(id.name, id.description); | 
| 46       } on FormatException catch(err) { | 54       } on FormatException catch(err) { | 
| 47         return false; | 55         return false; | 
| 48       } | 56       } | 
| 49 | 57 | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 110 | 118 | 
| 111     if (fileExists(dir)) { | 119     if (fileExists(dir)) { | 
| 112       throw new FormatException( | 120       throw new FormatException( | 
| 113           "Path dependency for package '$name' must refer to a " | 121           "Path dependency for package '$name' must refer to a " | 
| 114           "directory, not a file. Was '$dir'."); | 122           "directory, not a file. Was '$dir'."); | 
| 115     } | 123     } | 
| 116 | 124 | 
| 117     throw new FormatException("Could not find package '$name' at '$dir'."); | 125     throw new FormatException("Could not find package '$name' at '$dir'."); | 
| 118   } | 126   } | 
| 119 } | 127 } | 
| OLD | NEW | 
|---|