Project

General

Profile

Logged in as brainvisa
Watch Actions

Task #8806

closed

Windows : add support for long pathes (i.e. : > 255 characters)

Added by Souedet, Nicolas over 10 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
brainvisa-cmake
Start date:
29/11/2013
Due date:
% Done:

0%

Estimated time:

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:)

Actions #1

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

Actions #2

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

Actions #3

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')

Actions #4

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

Actions #5

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.5

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:)
------------------------------

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

Actions #6

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();
}

Actions #7

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)

Actions #8

Updated by Cointepas, Yann almost 9 years ago

  • Target version changed from development-4.5 to brainvisa-4.5
Actions #9

Updated by Cointepas, Yann almost 9 years ago

  • Assignee set to Souedet, Nicolas
Actions #10

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

Actions #11

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" 

Actions #12

Updated by Riviere, Denis over 6 years ago

  • Target version changed from brainvisa-4.6 to brainvisa-4.7
Actions #13

Updated by Riviere, Denis over 5 years ago

  • Category set to brainvisa-cmake
Actions #14

Updated by Souedet, Nicolas over 1 year ago

  • Status changed from New to Closed
Watch Actions

Also available in: Atom PDF