diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-09-03 05:55:12 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-09-03 05:55:12 +0000 |
commit | 2b2fbce16844c3d5b332820c067df94b22040df6 (patch) | |
tree | 5cb6211b9514ff353608f38c907009ed4546cc62 /fs/tempfs.py | |
parent | 974e63d7f370c2b75d4cc9a8f56e860b5829ebff (diff) | |
download | pyfilesystem-git-2b2fbce16844c3d5b332820c067df94b22040df6.tar.gz |
support long paths (>> 260 chars) on win32
Diffstat (limited to 'fs/tempfs.py')
-rw-r--r-- | fs/tempfs.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/tempfs.py b/fs/tempfs.py index 2b89dd1..644374f 100644 --- a/fs/tempfs.py +++ b/fs/tempfs.py @@ -1,8 +1,8 @@ #!/usr/bin/env python +import os from osfs import OSFS import tempfile -from shutil import rmtree class TempFS(OSFS): @@ -37,7 +37,15 @@ class TempFS(OSFS): if not self._cleaned and self.exists("/"): self._lock.acquire() try: - rmtree(self._temp_dir) + # shutil.rmtree doesn't handle long paths on win32, + # so we walk the tree by hand. + entries = os.walk(self.root_path,topdown=False) + for (dir,dirnames,filenames) in entries: + for filename in filenames: + os.remove(os.path.join(dir,filename)) + for dirname in dirnames: + os.rmdir(os.path.join(dir,dirname)) + os.rmdir(self.root_path) self._cleaned = True finally: self._lock.release() |