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

Issue 10417053: Add Path class to dart:io, and add unit tests for it. (Closed)

Created:
8 years, 7 months ago by Bill Hesse
Modified:
8 years, 6 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add Path class to dart:io, add tests for it to standalone/io. Just a preliminary implementation - make suggestions for changes. BUG= TEST=standalone/io/path_test Committed: https://code.google.com/p/dart/source/detail?r=8909

Patch Set 1 #

Patch Set 2 : more changes. #

Patch Set 3 : most recent version #

Patch Set 4 : Add tests, remove test_suite.dart changes. #

Patch Set 5 : Add unit tests for Path, remove test_suite changes. #

Total comments: 71

Patch Set 6 : Address comments, finish implementation (mostly). #

Total comments: 44

Patch Set 7 : Address comments. #

Total comments: 30

Patch Set 8 : Address comments. Add to docgen. #

Patch Set 9 : Fix 2 bugs. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+499 lines, -2 lines) Patch
M lib/compiler/implementation/lib/io.dart View 1 2 3 4 5 6 7 2 chunks +4 lines, -2 lines 0 comments Download
M runtime/bin/io_sources.gypi View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
A runtime/bin/path.dart View 1 2 3 4 5 6 7 1 chunk +167 lines, -0 lines 0 comments Download
A runtime/bin/path_impl.dart View 1 2 3 4 5 6 7 8 1 chunk +202 lines, -0 lines 0 comments Download
A tests/standalone/io/path_test.dart View 1 2 3 4 5 6 7 8 1 chunk +124 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Bill Hesse
Just a preliminary stab at it. Please make suggestions for changes. One design decision that ...
8 years, 7 months ago (2012-05-25 13:14:38 UTC) #1
Anders Johnsen
First round of comments. http://codereview.chromium.org/10417053/diff/7001/runtime/bin/path.dart File runtime/bin/path.dart (right): http://codereview.chromium.org/10417053/diff/7001/runtime/bin/path.dart#newcode9 runtime/bin/path.dart:9: Path(String source); I think we ...
8 years, 7 months ago (2012-05-25 13:37:30 UTC) #2
Søren Gjesse
http://codereview.chromium.org/10417053/diff/7001/runtime/bin/path.dart File runtime/bin/path.dart (right): http://codereview.chromium.org/10417053/diff/7001/runtime/bin/path.dart#newcode8 runtime/bin/path.dart:8: interface Path default _PathImpl { Each constructor/method should have ...
8 years, 6 months ago (2012-05-29 07:18:01 UTC) #3
Mads Ager (google)
I think the interface looks like a good start. Let's get this fully implemented! :) ...
8 years, 6 months ago (2012-05-29 07:36:02 UTC) #4
Bob Nystrom
DBC. I would also recommend you run this by Josh. I would really like us ...
8 years, 6 months ago (2012-05-30 17:58:37 UTC) #5
Bill Hesse
https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart File runtime/bin/path.dart (right): https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart#newcode8 runtime/bin/path.dart:8: interface Path default _PathImpl { On 2012/05/30 17:58:37, Bob ...
8 years, 6 months ago (2012-05-31 15:55:10 UTC) #6
Bob Nystrom
https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart File runtime/bin/path.dart (right): https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart#newcode8 runtime/bin/path.dart:8: interface Path default _PathImpl { On 2012/05/31 15:55:10, Bill ...
8 years, 6 months ago (2012-05-31 18:06:46 UTC) #7
Mads Ager (google)
On 2012/05/31 18:06:46, Bob Nystrom wrote: > https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart > File runtime/bin/path.dart (right): > > https://chromiumcodereview.appspot.com/10417053/diff/7001/runtime/bin/path.dart#newcode8 ...
8 years, 6 months ago (2012-06-01 07:26:31 UTC) #8
Mads Ager (google)
Next round of comments. https://chromiumcodereview.appspot.com/10417053/diff/3008/runtime/bin/path.dart File runtime/bin/path.dart (right): https://chromiumcodereview.appspot.com/10417053/diff/3008/runtime/bin/path.dart#newcode11 runtime/bin/path.dart:11: const Path(String source); Please document ...
8 years, 6 months ago (2012-06-01 08:11:31 UTC) #9
Bill Hesse
The interface and class are not showing up in the generated API docs - I ...
8 years, 6 months ago (2012-06-15 14:23:08 UTC) #10
Anders Johnsen
https://chromiumcodereview.appspot.com/10417053/diff/18001/runtime/bin/path.dart File runtime/bin/path.dart (right): https://chromiumcodereview.appspot.com/10417053/diff/18001/runtime/bin/path.dart#newcode54 runtime/bin/path.dart:54: Path canonicalize(); I'm not sure what I like the ...
8 years, 6 months ago (2012-06-18 06:27:08 UTC) #11
Søren Gjesse
LGTM with comments addressed. https://chromiumcodereview.appspot.com/10417053/diff/18001/runtime/bin/path.dart File runtime/bin/path.dart (right): https://chromiumcodereview.appspot.com/10417053/diff/18001/runtime/bin/path.dart#newcode12 runtime/bin/path.dart:12: interface Path default _PathImpl { ...
8 years, 6 months ago (2012-06-18 07:29:35 UTC) #12
Mads Ager (google)
To get the interfaces to show up in the generated documentation you have to add ...
8 years, 6 months ago (2012-06-18 07:35:31 UTC) #13
Bill Hesse
8 years, 6 months ago (2012-06-18 15:46:38 UTC) #14
http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart
File runtime/bin/path.dart (right):

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:12: interface Path default _PathImpl {
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Following the convention for the rest of dart:io default class should be just
> _Path (without Impl)

Done.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:33: * Is this path an absolute path, beginning with a path
separator?
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Should there be some additional information on Windows and drive letters? How
is
> a drive letter without a '/' before interpreted?

Done.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:52: * and combining consecutive path separators.
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> What happens if there are more '..'s that "real" segments? Exception?

Leading '..' segments are kept on relative paths, and dropped on absolute paths.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:58: * interpreting '.' and '..' as directory traversal
commands, and removing
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> The explanation of '.'  and '..' here is slightly different that for
> canonicalize. Maybe just say that the raw joined path is canonicalizeed to
avoid
> duplicating the description.

Done.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:79: * `further.canonicalize()` starts with '../' or equals
'..'.
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Is that sufficient? What about a [further] of 'x/../..'?

'x/../..'.canonicalize() is '..'.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:88: * case is not implemented yet.
On 2012/06/18 06:27:08, ajohnsen wrote:
> A few comments here.
> 1) Do you really mean "if no such path exists"? I thought this lib was purely
> acting as a String manipulator?
> 2) What do you mean by a case is not implemented? If something is not
> implementable, we should write it here. And AFAIK, there is a few cases
that'll
> not work out?

Done.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:96: * the leading path separator if the path starts with a
drive specification.
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Should the invariant here be that is the fromNative constructor was used that
> toNativePath should return the exact same string?

There are some corner cases, with mixed backward and forward slashes.  But in
general, yes.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:98: String toNativePath();
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> The name toNativePath indicate that a Path not a String is returned.

Could we say toNativeFilepath?  toNativepath?  toNativeFilesystemPath?

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:139: String get filename();
I think filename is a common noun, and not the same as file name.

On 2012/06/18 07:29:35, Søren Gjesse wrote:
> fileName (uppercase N)?

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path.dart#newc...
runtime/bin/path.dart:159: String get extension();
On 2012/06/18 06:27:08, ajohnsen wrote:
> With the classic case of .tar.gz, should we have a "fullExtension", or leave
it
> to the use to extract that?

We could add that.  or get extensions?
multipleExtensions?

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path_impl.dart
File runtime/bin/path_impl.dart (right):

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path_impl.dart...
runtime/bin/path_impl.dart:22: var clean = source.replaceAll('\\', '/');
I think this would be more complex. I can't think of a name shorter or more
expressive than '/'.

On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Maybe create static final fields for '/', '\\', ':', '.' and '..'.
> 
> static final String SEPARATOR = '/';
> ...

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path_impl.dart...
runtime/bin/path_impl.dart:48: throw new Exception(
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> We have UnsupportedOperationException and NotImplementedException - maybe use
> one of these instead.

Done.

http://codereview.chromium.org/10417053/diff/18001/runtime/bin/path_impl.dart...
runtime/bin/path_impl.dart:173: List result = path.split('/');
On 2012/06/18 07:29:35, Søren Gjesse wrote:
> Maybe cache the result of splitting?

I think this may be more trouble than it is worth.  If the user needs this
often, they could cache it.  And splitting may be pretty fast.

Powered by Google App Engine
This is Rietveld 408576698