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

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

Issue 11273041: Make first and last getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. 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/lib/file_system.dart ('k') | utils/pub/yaml/parser.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';
(...skipping 26 matching lines...) Expand all
37 * [File] objects. 37 * [File] objects.
38 */ 38 */
39 String join(part1, [part2, part3, part4]) { 39 String join(part1, [part2, part3, part4]) {
40 final parts = _getPath(part1).replaceAll('\\', '/').split('/'); 40 final parts = _getPath(part1).replaceAll('\\', '/').split('/');
41 41
42 for (final part in [part2, part3, part4]) { 42 for (final part in [part2, part3, part4]) {
43 if (part == null) continue; 43 if (part == null) continue;
44 44
45 for (final piece in _getPath(part).split('/')) { 45 for (final piece in _getPath(part).split('/')) {
46 if (piece == '..' && parts.length > 0 && 46 if (piece == '..' && parts.length > 0 &&
47 parts.last() != '.' && parts.last() != '..') { 47 parts.last != '.' && parts.last != '..') {
48 parts.removeLast(); 48 parts.removeLast();
49 } else if (piece != '') { 49 } else if (piece != '') {
50 if (parts.length > 0 && parts.last() == '.') { 50 if (parts.length > 0 && parts.last == '.') {
51 parts.removeLast(); 51 parts.removeLast();
52 } 52 }
53 parts.add(piece); 53 parts.add(piece);
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 return Strings.join(parts, Platform.pathSeparator); 58 return Strings.join(parts, Platform.pathSeparator);
59 } 59 }
60 60
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (workingDir != null) { 499 if (workingDir != null) {
500 options.workingDirectory = _getDirectory(workingDir).path; 500 options.workingDirectory = _getDirectory(workingDir).path;
501 } 501 }
502 options.environment = environment; 502 options.environment = environment;
503 503
504 var future = Process.run(executable, args, options); 504 var future = Process.run(executable, args, options);
505 return future.transform((result) { 505 return future.transform((result) {
506 // TODO(rnystrom): Remove this and change to returning one string. 506 // TODO(rnystrom): Remove this and change to returning one string.
507 List<String> toLines(String output) { 507 List<String> toLines(String output) {
508 var lines = output.split(NEWLINE_PATTERN); 508 var lines = output.split(NEWLINE_PATTERN);
509 if (!lines.isEmpty && lines.last() == "") lines.removeLast(); 509 if (!lines.isEmpty && lines.last == "") lines.removeLast();
510 return lines; 510 return lines;
511 } 511 }
512 return new PubProcessResult(toLines(result.stdout), 512 return new PubProcessResult(toLines(result.stdout),
513 toLines(result.stderr), 513 toLines(result.stderr),
514 result.exitCode); 514 result.exitCode);
515 }); 515 });
516 } 516 }
517 517
518 /** 518 /**
519 * Wraps [input] to provide a timeout. If [input] completes before 519 * Wraps [input] to provide a timeout. If [input] completes before
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return new Directory(entry); 748 return new Directory(entry);
749 } 749 }
750 750
751 /** 751 /**
752 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 752 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
753 */ 753 */
754 Uri _getUri(uri) { 754 Uri _getUri(uri) {
755 if (uri is Uri) return uri; 755 if (uri is Uri) return uri;
756 return new Uri.fromString(uri); 756 return new Uri.fromString(uri);
757 } 757 }
OLDNEW
« no previous file with comments | « utils/lib/file_system.dart ('k') | utils/pub/yaml/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698