charlievieth / fs

Cross platform Go wrapper for the os package to support long file names on windows.
MIT License
2 stars 2 forks source link

Expose path cleaning #1

Open cppforlife opened 7 years ago

cppforlife commented 7 years ago

@charlievieth what do you think about exposing some kind of function (absPath) to resolve paths so that generic code that works on windows/unix doesnt have to do cleaning? Here is an example PR that includes cleaning functionality:

https://github.com/cloudfoundry/bosh-utils/pull/11

charlievieth commented 7 years ago

I do not believe this can be done as the Windows versions of posix utilities differ in what paths they accept. PR #11 works with the tar included with git-bash, but breaks the tar included with cygwin and libarchive, which properly handles Windows paths. For example path C:\Windows is represented in: git-tar as /c/windows; and cygwin-tar as /cygdrive/c/windows.

That said, I've been debating exposing absPath, but I'm not sure how valuable it would be, as outside of the os package, which fs fully replicates, the most common situation in which MAX_PATH is violated is when walking directories and absPath does not know if a path will be walked. To handle this issue I do plan to add implement filepath.Walk with support for long paths in the fs package.