Author urbanp
Recipients
Date 2005-08-30.07:50:25
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The module tarfile has problems using os.stat() if the
filenames use direct device addressing on Windows systems. 
For example:
\\?\GLOBALROOT\Device\HarddiskVolume1\TEMP\1.txt

The following error is reported:
Traceback (most recent call last):
  File "C:\urbanp\py\test.py", line 9, in ?
   
tar.add('\\\\?\\GLOBALROOT\\Device\\HarddiskVolume1\\TEMP\\1.txt',
'TEMP\\1.txt')
  File "C:\PROGRA~1\Python23\lib\tarfile.py", line
1204, in add
    tarinfo = self.gettarinfo(name, arcname)
  File "C:\PROGRA~1\Python23\lib\tarfile.py", line
1080, in gettarinfo
    statres = os.lstat(name)
OSError: [Errno 2] No such file or directory:
'\\\\?\\GLOBALROOT\\Device\\HarddiskVolume1\\TEMP\\1.txt'

As a solution we can use win32file.GetFileAttributesEx().
I mapped win32file.GetFileAttributesEx result into a
tuple that has the same structure as a os.stat result
tuple. Therefore, the same variable can be used.

The reason for using direct device addressing is that I
need to create a tar package from a volume snapshot
(vss on Windows 2003) that cannot be mounted.
The solution also works on StorageCraft VSnap snapshots.
History
Date User Action Args
2007-08-23 15:43:47adminlinkissue1276378 messages
2007-08-23 15:43:47admincreate