-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ARROW-6622: [R] Normalize paths for filesystem API on Windows #5445
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
context("test-type") | ||
context("File system") | ||
|
||
test_that("LocalFilesystem", { | ||
fs <- LocalFileSystem$create() | ||
|
@@ -83,7 +83,6 @@ test_that("SubTreeFilesystem", { | |
expect_is(st_fs, "FileSystem") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you should simply /-normalize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At worse you simply string-replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's where I ended up: https://github.com/apache/arrow/pull/5445/files#diff-3bd936ee39b8abe149e5399681610c75R255 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, then you shouldn't call it |
||
st_fs$CreateDir("test") | ||
st_fs$CopyFile("DESCRIPTION", "DESC.txt") | ||
skip_on_os("windows") # See ARROW-6622 | ||
stats <- st_fs$GetTargetStats(c("DESCRIPTION", "test", "nope", "DESC.txt")) | ||
expect_equal(stats[[1L]]$type, FileType$File) | ||
expect_equal(stats[[2L]]$type, FileType$Directory) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably use
.Platform$file.sep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not sure about the name of this function, it is not really doing anything to compute a relative path, you could probably just use
normalizePath(mustWork = FALSE)
, assuming path doesn't actually have to exist on the filesystem.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re:
.Platform$file.sep
, I intended to but then on my Windows VM,.Platform$file.sep
reported "/" whiletempfile()
still created paths with "\" 🤷♂I originally did
normalizePath
but unfortunately for this use case,normalizePath
does path expansion, even withmustWork=FALSE
. We need to keep the path relative (to whatever the FileSystem object holds as its cwd) and just need Windows\
to be converted to/
. Regular expressions were my last resort and I'm happy to use something better or more robust if it exists.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks a bit weird to do a no-op replacement on Unix, though I suppose it doesn't work.