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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/path.dart
diff --git a/runtime/bin/path.dart b/runtime/bin/path.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5266671fccd6dadcb3648099e75bfed0a634e022
--- /dev/null
+++ b/runtime/bin/path.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * A Path, interpreted as a sequence of strings separated by forward slashes.
+ */
+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
+ 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(
+ const Path.c(String source);
Søren Gjesse 2012/05/29 07:18:01 What does the Path.c constructor do?
+
+ bool get isEmpty();
+ bool get isAbsolute();
+ 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().
+ bool get isCanonical();
+
+ Path canonicalize();
+ 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.
+ 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.
+
+ /**
+ * Converts a path to a string using the native filesystem's conventions.
+ */
+ String toNativePath();
+
+ // '$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.
+ // '${foo.filename}' == '${foo.basename()}.${foo.extension()}' if
+ // 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.
+ 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.
+ String filename(); // or get filename
+ String basename(); // or get filenameWithoutExtension
+ 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
+}
+
+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.
+ const PathException([String this.message]);
+ String toString() => "PathException: $message";
+ final String message;
+}

Powered by Google App Engine
This is Rietveld 408576698