News for hackers. Stuff that matters.
Re:Fix 260 character file name length limitation: Declined by chao- on Monday October 07, 2013 @03:40PM (#6510670)
I was made aware of this artificial limitation through a pretty vivid edge case while I a student some years ago. TortoiseSVN had somehow borked and began to recursively create .svn directories inside of each other, as fast as it could, until such time as I managed to kill the process.

Many can guess what happened next: I went to delete the erroneous top-level .svn folder and was given an error, the gist of which was: "Cannot remove. Path too long." There's more to the story, but it turns out the real answer was to boot into a Linux LiveCD and delete from within there.

I found it strange that one set of Win32 calls allowed TortoiseSVN to create paths of a certain depth, but the other set, used by Microsoft in their tools, would not allow me to delete them. These days I understand the reasons behind it, and so instead find it merely annoying.

Re:Fix 260 character file name length limitation: Declined by fleitz on Monday October 07, 2013 @04:28PM (#6511020)
This is only related to the path, if you recursively delete from the top level then it doesn't work, but if you switch CWD to a lower level directory then you can delete the files.

eg.

  rm -rf C:/REALLY/LONG/PATH/ 
  doesn't work but
  cd REALLY
  cd LONG
  rm -rf PATH
  cd ..
  rm -rf LONG
  cd ..
  rm -rf REALLY 
  works (windows equivalents of course)
In past projects I've ended up rewriting most of of System.IO that dealt with paths to fix this issue. Basically all you have to do is prefix your path with \\?\ and voila it works. (Except in .NET which detects you're doing this and stops it)
Re:Fix 260 character file name length limitation: Declined by mzs on Monday October 07, 2013 @06:23PM (#6511714)
I just googled \\?\ and got no results because google just is that way. Can you explain more about that please.
Re:Fix 260 character file name length limitation: Declined by dpedigo on Monday October 07, 2013 @06:40PM (#6511796)
The following should explain a bit better than I could: http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29....
Re:Fix 260 character file name length limitation: Declined by brutos on Monday October 07, 2013 @06:42PM (#6511812)
It's hard to Google, but that syntax is called UNC: http://en.wikipedia.org/wiki/Path_(computing)#Uniform_Naming...
Re:Fix 260 character file name length limitation: Declined by fleitz on Monday October 07, 2013 @07:46PM (#6512092)
As other posters have said it's UNC, however if you're interested in other weirdness around files in Windows, checkout NTFS streams.
Re:Fix 260 character file name length limitation: Declined by mdmarra on Monday October 07, 2013 @09:59PM (#6512558)
A UNC always references a network path. You can use \\?\ to reference a network path, but it can also be used to reference a local path too. \\?\ is not always used to represent a UNC.

\\?\ is an extended-length path.

Re:Fix 260 character file name length limitation: Declined by tekacs on Wednesday October 09, 2013 @02:21PM (#6522881)
\\?\ is an unparsed path - the path is passed directly to the filesystem, bypassing checks and other Win32 API restrictions - a side effect of this is that maximum length checks are bypassed, but this is NOT the only effect.

See GP's link for more details.

Re:Fix 260 character file name length limitation: Declined by ohaal on Tuesday October 08, 2013 @03:26AM (#6513484)
Re:Fix 260 character file name length limitation: Declined by VLM on Monday October 07, 2013 @05:27PM (#6511393)
This is going to look linux because I don't use windows, but you can automate this by writing two scripts and putting both in your path

#!/bin/bash

while [ 1 ]

do

  cd .svn
done

The other looks like this

#!/bin/bash

while [ 1 ]

do

  cd ..

  rm -Rf *
done

Now just run the first until it can't cd any deeper, and then run the second to clean your hard drive very throughly.

(note I know darn well what script #2 does ... this would probably make a good debugging question for a sysadmin interview... in case you don't get it, for gods sake don't run script #2 unchanged)

Re:Fix 260 character file name length limitation: Declined by eksith on Monday October 07, 2013 @09:41PM (#6512483)
Actually I saw script #2 on an interview question a little while back (not that the interviewer knew what it did; he didn't seem to have a programming background). Don't exactly recall what the question was, but it was something to the effect of "what are your thoughts on the safety of the following script" or the like.

The good thing about nix platforms is that you have nuclear options at your fingertips. The bad thing is that you can't be impulsive or an idiot because you have nuclear options at your fingertips ;)

Re:Fix 260 character file name length limitation: Declined by VLM on Tuesday October 08, 2013 @07:50AM (#6514199)
Ditto here, it must have been a management interview fad a decade or two ago. The sysadmin version of fizzbuzz. My particular version was one page script that wiped an existing software installation (and a bit more LOL) and dropped a new version on top of it. The kind of thing that has pretty much been eliminated by using git/etc as a distribution tech and/or puppet.

So VLM... nice to meet you, here's the first version of our software upgrade script I was wondering what you'd change. I started laughing, pointed out a few things, he said I passed.

It had a lot more wrong with it. Weird quoting mistakes (single vs double, also something along the lines of grep "-R blah blah"). And there were basic conceptual issues, like copying the binaries to /usr/local/bin before replacing the old distribution with the new one, such that you'd get old ones. And the path contained a version number and the script tried to change user PATH env variables ... to the old version path.

The proper interview-style fix for my creative solution would be something like rm -Rf .svn instead of rm -Rf *, or bothering to check the output of pwd is longer than X characters using grep -c and some comparisons or playing games with chroot. Its a great interview question because you get a feel for the candidates style, are they most comfortable with chroot, or doing text manipulations of pwd etc or are they a minimalist who likes to make the smallest possible change or into rewriting the whole blasted thing or...

Re:Fix 260 character file name length limitation: Declined by hobs on Monday October 07, 2013 @09:06PM (#6512360)
>in case you don't get it, for gods sake don't run script #2 unchanged", fairly harsh...

Down voting a guy who does have a warning? However for safety's sake, I would recommend prefacing the code with a warning instead of having it at the end.

Re:Fix 260 character file name length limitation: Declined by fleitz on Monday October 07, 2013 @07:44PM (#6512083)
You should post both scripts unaltered to stack overflow for the LULZ.
Re:Fix 260 character file name length limitation: Declined by justinweiss on Monday October 07, 2013 @07:35PM (#6512052)
When I was still at MS, a lot of these kind of bugs didn't get fixed -- the code checking against the old (smaller) path size would often not be owned by anyone anymore, and nobody wanted to touch it (because that would make them the new owner).
Re:Fix 260 character file name length limitation: Declined by badman_ting on Monday October 07, 2013 @04:43PM (#6511119)
THIS is what is so crazy-making about this problem. You can keep all your own paths you make intentionally under 260 no problem, but when a piece of code screws up and goes over, it can make your life hell. Over a stupid file.

If they're not going to fix the problem, and I respect why they're not going to, at least make it easier to work around. It just seems like on Windows you often have to deal with silly, incredibly annoying problems like this that other platforms don't have.

Re:Fix 260 character file name length limitation: Declined by mdmarra on Monday October 07, 2013 @09:55PM (#6512535)
If you ever want to fix an issue like this in the future, it's very easy to just create an empty folder on c:\ named something like "empty" and use robocopy to mirror the empty folder into the folder that is too deep.

robocopy c:\empty c:\so_many_subdirectories /mir will do the trick.

Re:Fix 260 character file name length limitation: Declined by qwerta on Monday October 07, 2013 @05:36PM (#6511443)
NTFS has actual support for hard file links, but only usage I ever seen was for jokes similar to this one.
Re:Fix 260 character file name length limitation: Declined by Aloha on Monday October 07, 2013 @05:53PM (#6511551)
I use junction/hard links to alias part of my filesystem into dropbox. There is a real use case for it.
Re:Fix 260 character file name length limitation: Declined by joe_bleau on Monday October 07, 2013 @09:27PM (#6512436)
I use them for snapshots.
Re:Fix 260 character file name length limitation: Declined by nivla on Monday October 07, 2013 @09:07PM (#6512362)
I use them as OS based file versioning for my backups.
Re:Fix 260 character file name length limitation: Declined by cryptos on Monday October 07, 2013 @03:43PM (#6510684)
Same here, but with Windows' own backup tool.
Re:Fix 260 character file name length limitation: Declined by kijin on Tuesday October 08, 2013 @12:48AM (#6513109)
I had a similarly annoying experience, but with Dropbox.

On my Ubuntu PC, I created an encrypted folder in my Dropbox using EncFS. Turns out EncFS produces very long folder names and file names if you use the default, most secure setting with per-file IVs. Still, everything worked fine until I booted my Windows PC. As soon as Dropbox started trying to sync with the Windows PC, it ran into the 260-char path length limit and quietly began to truncate their names. Result: corrupted EncFS folder.

Re:Fix 260 character file name length limitation: Declined by stelonix on Tuesday October 08, 2013 @12:46AM (#6513101)
The same issue happened to me some years ago. The solution to get rid of .svn directories was to use a simple robocopy script I found online (ntfs-3g support for writing was rudimentary back then).