Chromium Code Reviews| Index: utils/pub/io.dart |
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
| index cccedfc17b93098bafde5f6847aaa8d9023ba6a5..61d3170db9efea460666ce1c02b5a6ab92251605 100644 |
| --- a/utils/pub/io.dart |
| +++ b/utils/pub/io.dart |
| @@ -373,12 +373,25 @@ Future<File> createPackageSymlink(String name, from, to, |
| }); |
| } |
| -/** |
| - * Given [entry] which may be a [String], [File], or [Directory] relative to |
| - * the current working directory, returns its full canonicalized path. |
| - */ |
| -// TODO(rnystrom): Should this be async? |
| -String getFullPath(entry) => new File(_getPath(entry)).fullPathSync(); |
| +/// Given [entry] which may be a [String], [File], or [Directory] relative to |
| +/// the current working directory, returns its full canonicalized path. |
| +String getFullPath(entry) { |
| + var path = _getPath(entry); |
| + |
| + // Don't do anything if it's already absolute. |
| + if (Platform.operatingSystem == 'windows') { |
| + // An absolute path on Windows is either UNC (two leading backslashes), |
| + // or a drive letter followed by a colon and a slash. |
| + const ABSOLUTE = const RegExp(r'^(\\|[a-zA-Z]:[/\\])'); |
|
nweiz
2012/11/08 00:23:30
Doesn't the first branch of this match only only l
Bob Nystrom
2012/11/08 00:25:18
It's a raw string, so it should be two, I think.
|
| + if (ABSOLUTE.hasMatch(path)) return path; |
| + } else { |
| + if (path.startsWith('/')) return path; |
| + } |
| + |
| + // Using Path.join here instead of File().fullPathSync() because the former |
| + // does not require an actual file to exist at that path. |
| + return new Path.fromNative(workingDir).join(new Path(path)).toNativePath(); |
| +} |
| // TODO(nweiz): make this configurable |
| /** |