Task #8806
closedWindows : add support for long pathes (i.e. : > 255 characters)
0%
Description
On windows OS [at least XP and 7, may be 8 (to be checked)], there is limitation about path length (which must not exceed 255 characters).
This leads to annoying consequences :
1°) It is not possible to package brainvisa with bv_installer
2°) It is not possible to unzip and run packs in a long directory (we highly recommend to unzip brainvisa pack in c:)
Updated by Souedet, Nicolas over 10 years ago
The main workaround to address this issue is to use prefix '\\?\' before pathes.
In a DOS shell the following command works :
mkdir \\?\c:\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678
whereas the following command leads to the error 'File path or extension too long.'
mkdir c:\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678\a12345678
Updated by Souedet, Nicolas over 10 years ago
Moreover, regarding http://bugs.python.org/issue18199, some python functions do not support unc pathes with \\?\ prefix
Updated by Souedet, Nicolas over 10 years ago
The following pyaims script fails to create image in a directory with long path :
from soma import aims i = aims.AimsData_RGB(1,1,1) i.fill(aims.AimsRGB(0,0,0)) aims.write(i, u'\\\\?\\c:\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\test.ima')
Updated by Souedet, Nicolas over 10 years ago
Informations about the Windows long path limitation are available here http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
Updated by Cointepas, Yann over 10 years ago
An important point about long path names under Windows:
Because you cannot use the "\\?\" prefix with a relative path, relative
paths are always limited to a total of MAX_PATH characters.
Yann Cointepas Tel: +33 1 69 08 78 31
CEA - Neurospin Fax: +33 1 69 08 79 80
Bâtiment 145, Point Courrier 156
91191 Gif-sur-Yvette cedex, France
On Fri, Nov 29, 2013 at 12:39 PM, wrote:
La demande #8806 a été mise à jour par Souedet, Nicolas.
Informations about the Windows long path limitation are available here
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
------------------------------
*Task #8806: Windows : add support for long pathes (i.e. : > 255
characters) *- Auteur: Souedet, Nicolas
- Statut: New
- Priorité: Normal
- Assigné à:
- Catégorie:
- Version cible: development-4.5On windows OS [at least XP and 7, may be 8 (to be checked)], there is
limitation about path length (which must not exceed 255 characters).
This leads to annoying consequences :
1°) It is not possible to package brainvisa with bv_installer
2°) It is not possible to unzip and run packs in a long directory (we
highly recommend to unzip brainvisa pack in c:)
------------------------------You have received this notification because you have either subscribed to
it, or are involved in it.
To change your notification preferences, please click here:
https://bioproj.extra.cea.fr/redmine/my/account
Updated by Souedet, Nicolas over 10 years ago
The only way I found to create long file pathes using mingw compiler under Windows is to use non standard C function _wfopen() with unicode filenames ...
#include <iostream> #include <string> #include <stdio.h> int main(const int argc, const char **argv) { std::wstring fname = L"\\\\?\\c:\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\toto.txt"; FILE *pf = _wfopen(fname.c_str(), L"w"); fprintf( pf, "The file 'crt_fopen.c' was opened\n" ); fclose( pf ); }
Standard C++ version does not work (it does not raises exception but simply does not create the file) :
#include <fstream> #include <iostream> #include <string> int main(const int argc, const char **argv) { std::string fname = "\\\\?\\c:\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\a12345678\\iostream_cpp.txt"; std::ofstream ofs(fname.c_str()); ofs << "The file was opened" << std::endl; ofs.close(); }
Updated by Souedet, Nicolas over 10 years ago
An interesting Python library to deal with path issues on multiple OS : https://pathlib.readthedocs.org/en/latest/ (I am not sure it deals with the Windows long path issue)
Updated by Cointepas, Yann almost 9 years ago
- Target version changed from development-4.5 to brainvisa-4.5
Updated by Souedet, Nicolas over 8 years ago
- Target version changed from brainvisa-4.5 to brainvisa-4.6
Won't be fixed in 4.5 release
Updated by Souedet, Nicolas over 8 years ago
It can have an interest at building time to mount long path directories to drives.
A first way is to use the subst command.
subst F: C:\bv\build-bug_fix-Windows-7-i686-release
A second way that allow to keep permanent drives is to edit the registry keys like in the following example:
REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices] "F:"="\\??\\C:\\bv\\build-bug_fix-Windows-7-i686-release" "G:"="\\??\\C:\\bv\\build-trunk-Windows-7-i686-release"
Updated by Riviere, Denis over 6 years ago
- Target version changed from brainvisa-4.6 to brainvisa-4.7