?

Log in

 
 
31 October 2006 @ 02:06 pm
Windows doesn't help you see  
Yes, that subject is grammatically correct. I am referring the long file names in Windows, and whether they are visible or not. Mostly not, as I've found from recent experience with CVS and a Java project with a deep package structure. This leads to "No such file or directory" errors, an inability to manipulate the file with Explorer, and other goodies. Essentially, if you do a bit of Googling for 'windows MAX_PATH' then you'll find out that certain of Windows' file handling APIs are restricted to 255 character paths. This manifests itself in serious problems when trying to use CVSNT or similar utilities with long paths. Apparently, Windows' Unicode APIs don't have this restriction, but it seems that Windows Explorer doesn't even use them because the offending files cannot be manipulated from there - no Rename, no Delete, no nothing. If you try to delete the file in a command prompt window then you get a lovely error saying:
The filename or extension is too long.
As an example of the problem, I have a particular class file which is called:
uk\org\cough\develop\oranges\signed\fishandchipshops\modems\trackmylamps\
  widgetland\command\display\GetAppleAdjustmentPrimaryOrangeRefDataHandle.java
. Obviously I have changed the names to protect the guilty, but the length is right. The source is nicely modular so this sits inside a source folder which is components\actions\fishandchipshops_commandactions\src. This sits inside a folder called MyApp v1.20 which sits inside my Eclipse workspace, which is in C:\Documents and Settings\X123456\workspace. OK, so the total path is pretty huge, but none of these things are unreasonable (except possibly for the package depth, but that's not mine to alter). Trying to cvs update this folder even from lower down the tree gives errors like:
cvs: update (warning): uk\org\cough\develop\oranges\signed\fishandchipshops\
modems\trackmylamps\widgetland\command\display\
GetAppleAdjustmentPrimaryOrangeRefDataHandle.java is lost

cvs: update (warning): uk\org\cough\develop\oranges\signed\fishandchipshops\
modems\trackmylamps\widgetland\command\display\
GetAppleAdjustmentPrimaryOrangeRefDataHandle.java: No such file or directory
If I navigate with Windows Explorer to this file, I can't do anything with it except Open or Edit it. There are two workarounds:
  1. Use tools that use the Windows Unicode APIs exclusively. This is difficult, because the Windows GUI itself doesn't.
  2. Use SUBST. SUBST lets you map a drive letter to path. By cutting out the path to my workspace directory, I could save myself 40 characters and make this all work (until someone creates an even deeper, even longer-named source file):
    SUBST P: C:\Documents and Settings\X123456\workspace
    Once this is done, do your CVS commands from the P: drive instead of the C: drive and the path is short enough. Hoorah!