Monday, July 29, 2013

Sidestepping Windows NTFS Path Length Limitations

I was trying to compare a set of tests in Quality Center (QC) against some test scripts I had on a network drive. I decided to dump the QC tests to folders, so I can use "Beyond Compare" to make the comparison.

Problem:

The problem I hit however, was the path length limitation of NTFS. It seems that although NTFS allows quite long path names (around 32767 character) the dos path can't be more than 259 (or something like that). 

Lots of the tests, and most of the folders, in our test tree have long names, meaning we were easily hitting this limit. 

Solution:

Remembering that NTFS allows symbolic links (through the "mklink" command) I decided to:
  • For each folder in QC
    • Create a folder C:\Dump\[QC folder id]
    • Create a symlink in it's parent folder (C:\Dump\[QC parent folder id]\[full name of the folder]) to the C:\Dump\[QC folder id]
  • Dump the tests in the C:\Dump\[QC folder id] folders, naming the files to match the test names. 
This gave me a tree of symlink folders I could navigate that matched the QC folders exactly. Beyond Compare 3.2+ has an option to follow symlinks, which makes this all useful.

Gotchas:

My export script is written in Ruby. I hit a problem trying to execute `mklink /D #{from} #{to}` directly from Ruby. In the end I made a simple bat file:

mklink /d %1 %2

which I called from ruby

puts `link.bat "#{from}" "#{to}"`

See the source at https://gist.github.com/NigelThorne/6102634


Post a Comment

GitHub Projects