206 The filename or extension is too long / OSError: [Errno 38] Filenametoo long

Discussion in 'Python' started by robert, Jul 1, 2006.

  1. robert

    robert Guest

    e.g. open/os module functions (os.path.getmtime...) and
    win32api/win32file functions fail on long paths (>~255 chars)

    even the '\\?\' trick from
    http://www.google.com/url?sa=D&q=ht...rl=/library/en-us/fileio/fs/naming_a_file.asp
    does not work:

    >>> os.path.getmtime('\\\\?\\'+fabs)

    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    File "C:\PYTHON23\lib\ntpath.py", line 232, in getmtime
    return os.stat(filename).st_mtime
    OSError: [Errno 38] Filename too long
    >>>


    >>> win32api.GetFileAttributes('\\\\?\\'+fabs)

    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    error: (206, 'GetFileAttributes', 'Der Dateiname oder die Erweiterung
    ist zu lang.')
    >>>


    (='206 The filename or extension is too long')

    What can I do?


    -robert
     
    robert, Jul 1, 2006
    #1
    1. Advertising

  2. Re: 206 The filename or extension is too long / OSError: [Errno 38] Filename too long

    On Sat, 01 Jul 2006 12:32:09 +0200, robert <>
    declaimed the following in comp.lang.python:


    http://www.google.com/url?sa=D&q=ht...rl=/library/en-us/fileio/fs/naming_a_file.asp

    Note that this link (was it necessary to include the google
    indirection?) specifies the use of the Unicode variations of functions.
    In win32file, the Unicode versions are those with a "W" at the end of
    the function name:

    GetDriveTypeW() vs GetDriveType() for example; or
    CreateFileW() vs CreateFile()

    Just adding the prefix string alone doesn't, to my understanding,
    cause an automatic usage of the Unicode functions.

    > does not work:
    >
    > >>> os.path.getmtime('\\\\?\\'+fabs)

    > Traceback (most recent call last):
    > File "<interactive input>", line 1, in ?
    > File "C:\PYTHON23\lib\ntpath.py", line 232, in getmtime
    > return os.stat(filename).st_mtime
    > OSError: [Errno 38] Filename too long
    > >>>

    >
    > >>> win32api.GetFileAttributes('\\\\?\\'+fabs)


    win32api.GetFileAttributesW(...)

    >
    > What can I do?
    >

    Well... You can use the Windows Explorer to travel down the
    directory to someplace in the middle of the path, then move (drag) the
    directory to some top-level on the partition. That may make the rest of
    the path short enough to be used.
    --
    Wulfraed Dennis Lee Bieber KD6MOG

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Jul 1, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Harrison

    getting errno from OSError exception?

    Mark Harrison, Sep 13, 2004, in forum: Python
    Replies:
    1
    Views:
    430
    George Yoshida
    Sep 13, 2004
  2. Alec Wysoker
    Replies:
    11
    Views:
    15,462
    Alec Wysoker
    Jan 12, 2006
  3. mynthon
    Replies:
    5
    Views:
    2,031
    krowey
    Feb 9, 2013
  4. robert
    Replies:
    1
    Views:
    476
    Tim Golden
    Jun 24, 2009
  5. Chris Hulan
    Replies:
    2
    Views:
    263
    Steven D'Aprano
    Apr 3, 2013
Loading...

Share This Page