Is it safe to convert Windows file paths to Unix file paths with a simple replace?
- by MxyL
So for example say I had it so that all of my files will be transferred from a windows machine to a unix machine as such: C:\test\myFile.txt to {somewhere}/test/myFile.txt (drive letter is irrelevant at this point).
Currently, our utility library that we wrote ourselves provides a method that does a simple replace of all back slashes with forward slashes:
public String normalizePath(String path) {
return path.replaceAll("\\", "/");
}
Slashes are reserved and cannot be part of a file name, so the directory structure should be preserved. However, I'm not sure if there are other complications between windows and unix paths that I may need to worry about (eg: non-ascii names, etc)