Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add repalcePathSeparator #10

Closed
wants to merge 1 commit into from

Conversation

sunglim
Copy link
Contributor

@sunglim sunglim commented Dec 15, 2013

This repalcePathSeparator reduces the code size, and useful to support multi platform environment.

TEST=./grind tests

if (Platform.isWindows) {
return path.replaceAll('/', Platform.pathSeparator);
} else {
return path.replaceAll('\\', Platform.pathSeparator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, does this make sense? I think you're including it for completeness. \ is a valid path char on unix OSes, although probably never used. Perhaps, the semantics of replacePathSeparator() can be changed slightly, to essentially allow '/' paths - unix or web paths - to work on windows?

I think this change is ok as is, or just as

if (Platform.isWindows) {
  return path.replaceAll('/', Platform.pathSeparator);
}

no strong feelings either way -

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, just swtiching char is not perfect. and if replacePathSeperator work only windows, it's not useful.
closing then.

@sunglim sunglim closed this Dec 16, 2013
@devoncarew
Copy link
Contributor

I have in the past used

path = path.replaceAll('/', Platform.pathSeparator);

in order to let unix and url paths ('/') work on windows. So, one path (foo/bar/baz) works on all OSes after being processed w/ the above replaceAll call. It's a shortcut to building up paths by joining components w/ the path separator. Perhaps this is not what you had in mind for replacePathSeparator()?

I can add this call in, but I think there'd also be room for something called normalizePath(), which only did the / ==> Platform.pathSeparator conversion.

@sunglim
Copy link
Contributor Author

sunglim commented Dec 16, 2013

Well I think passing paths as string still imply issues. It is probably necessary to create FilePath class, something like a chromium FilePath https://code.google.com/p/chromium/codesearch#chromium/src/base/files/file_path.h

And remove all the String path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants