Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: utils/pub/io.dart

Issue 11312203: "Reverting 14829-14832" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/version.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * Helper functionality to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 library io; 8 library io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
11 import 'dart:isolate'; 11 import 'dart:isolate';
12 import 'dart:uri'; 12 import 'dart:uri';
13 13
14 import 'utils.dart'; 14 import 'utils.dart';
15 15
16 bool _isGitInstalledCache; 16 bool _isGitInstalledCache;
17 17
18 /// The cached Git command. 18 /// The cached Git command.
19 String _gitCommandCache; 19 String _gitCommandCache;
20 20
21 /** Gets the current working directory. */ 21 /** Gets the current working directory. */
22 String get currentWorkingDir => new File('.').fullPathSync(); 22 String get currentWorkingDir => new File('.').fullPathSync();
23 23
24 final NEWLINE_PATTERN = new RegExp("\r\n?|\n\r?"); 24 const Pattern NEWLINE_PATTERN = const RegExp("\r\n?|\n\r?");
25 25
26 /** 26 /**
27 * Prints the given string to `stderr` on its own line. 27 * Prints the given string to `stderr` on its own line.
28 */ 28 */
29 void printError(value) { 29 void printError(value) {
30 stderr.writeString(value.toString()); 30 stderr.writeString(value.toString());
31 stderr.writeString('\n'); 31 stderr.writeString('\n');
32 } 32 }
33 33
34 /** 34 /**
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 /// Given [entry] which may be a [String], [File], or [Directory] relative to 376 /// Given [entry] which may be a [String], [File], or [Directory] relative to
377 /// the current working directory, returns its full canonicalized path. 377 /// the current working directory, returns its full canonicalized path.
378 String getFullPath(entry) { 378 String getFullPath(entry) {
379 var path = _getPath(entry); 379 var path = _getPath(entry);
380 380
381 // Don't do anything if it's already absolute. 381 // Don't do anything if it's already absolute.
382 if (Platform.operatingSystem == 'windows') { 382 if (Platform.operatingSystem == 'windows') {
383 // An absolute path on Windows is either UNC (two leading backslashes), 383 // An absolute path on Windows is either UNC (two leading backslashes),
384 // or a drive letter followed by a colon and a slash. 384 // or a drive letter followed by a colon and a slash.
385 var ABSOLUTE = new RegExp(r'^(\\\\|[a-zA-Z]:[/\\])'); 385 const ABSOLUTE = const RegExp(r'^(\\\\|[a-zA-Z]:[/\\])');
386 if (ABSOLUTE.hasMatch(path)) return path; 386 if (ABSOLUTE.hasMatch(path)) return path;
387 } else { 387 } else {
388 if (path.startsWith('/')) return path; 388 if (path.startsWith('/')) return path;
389 } 389 }
390 390
391 // Using Path.join here instead of File().fullPathSync() because the former 391 // Using Path.join here instead of File().fullPathSync() because the former
392 // does not require an actual file to exist at that path. 392 // does not require an actual file to exist at that path.
393 return new Path.fromNative(currentWorkingDir).join(new Path(path)) 393 return new Path.fromNative(currentWorkingDir).join(new Path(path))
394 .toNativePath(); 394 .toNativePath();
395 } 395 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 return new Directory(entry); 775 return new Directory(entry);
776 } 776 }
777 777
778 /** 778 /**
779 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 779 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
780 */ 780 */
781 Uri _getUri(uri) { 781 Uri _getUri(uri) {
782 if (uri is Uri) return uri; 782 if (uri is Uri) return uri;
783 return new Uri.fromString(uri); 783 return new Uri.fromString(uri);
784 } 784 }
OLDNEW
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/version.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698