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

Side by Side Diff: runtime/bin/path.dart

Issue 10417053: Add Path class to dart:io, and add unit tests for it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add unit tests for Path, remove test_suite changes. Created 8 years, 6 months 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * A Path, interpreted as a sequence of strings separated by forward slashes.
7 */
8 interface Path default _PathImpl {
Søren Gjesse 2012/05/29 07:18:01 Each constructor/method should have a documentatio
Bob Nystrom 2012/05/30 17:58:37 Why isn't Path a class?
Bill Hesse 2012/05/31 15:55:10 Only so that the interface is clear to the reader
Bob Nystrom 2012/05/31 18:06:46 The interface is clear either way: they'll see a t
9 Path(String source);
Anders Johnsen 2012/05/25 13:37:30 I think we should have - const Path(source) - Path
Mads Ager (google) 2012/05/29 07:36:02 I agree that it should be a const constructor. The
Bill Hesse 2012/05/31 15:55:10 Path() is now a const constructor Path.fromNative(
10 const Path.c(String source);
Søren Gjesse 2012/05/29 07:18:01 What does the Path.c constructor do?
11
12 bool get isEmpty();
13 bool get isAbsolute();
14 bool get isDirectory();
Anders Johnsen 2012/05/25 13:37:30 Since it have no knowledge of the underlying syste
Bill Hesse 2012/05/31 15:55:10 Now called get hasTrailingSlash().
15 bool get isCanonical();
16
17 Path canonicalize();
18 Path join(further); // further is Path or String.
Anders Johnsen 2012/05/25 13:37:30 Comment in /** ... **/ so we can mark it with as [
Mads Ager (google) 2012/05/29 07:36:02 Yes, and please add doc comments to all of these s
Bill Hesse 2012/05/31 15:55:10 Done.
19 Path relativeTo(Path base);
Anders Johnsen 2012/05/25 13:37:30 I'm in favor of relativePathTo, or pathRelativeTo,
Mads Ager (google) 2012/05/29 07:36:02 On the other hand, all of the getters in the inter
Bob Nystrom 2012/05/30 17:58:37 +1 to Mads.
Bill Hesse 2012/05/31 15:55:10 Done.
20
21 /**
22 * Converts a path to a string using the native filesystem's conventions.
23 */
24 String toNativePath();
25
26 // '$foo' == '${foo.dirname()}/${foo.filename()}' if dirname is nonempty.
Mads Ager (google) 2012/05/29 07:36:02 I don't understand these comments.
Bill Hesse 2012/05/31 15:55:10 Done.
27 // '${foo.filename}' == '${foo.basename()}.${foo.extension()}' if
28 // foo.extension() is nonempty.
Søren Gjesse 2012/05/29 07:18:01 I am in favor of these being getters. Regarding th
Bob Nystrom 2012/05/30 17:58:37 +1. These should be getters.
Bill Hesse 2012/05/31 15:55:10 Done.
Bill Hesse 2012/05/31 15:55:10 Done.
29 Path dirname(); // or get directoryPath
Anders Johnsen 2012/05/25 13:37:30 IMO, dirname != directoryPath. E.g.: /my/path/to/
Søren Gjesse 2012/05/29 07:18:01 I agree with Anders that we should use "directory"
Bill Hesse 2012/05/31 15:55:10 Done.
30 String filename(); // or get filename
31 String basename(); // or get filenameWithoutExtension
32 String extension(); // or get extension
Søren Gjesse 2012/05/29 07:18:01 How about mentioning toString and document what it
Bill Hesse 2012/05/31 15:55:10 toNativePath is what I called toPlatformString, bu
33 }
34
35 class PathException implements Exception {
Bob Nystrom 2012/05/30 17:58:37 I don't think you should have this. We should only
Bill Hesse 2012/05/31 15:55:10 Done.
36 const PathException([String this.message]);
37 String toString() => "PathException: $message";
38 final String message;
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698