]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP 2235-long-paths-on-windows-3
authorDaira Hopwood <daira@jacaranda.org>
Tue, 9 Sep 2014 17:35:53 +0000 (18:35 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 9 Sep 2014 17:35:53 +0000 (18:35 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/util/fileutil.py

index e71ddb4d8f1a3990bc5a1bd559012adf3da9f63e..582139e1d19deff7a33326f924b7250be919e875 100644 (file)
@@ -218,15 +218,18 @@ def rm_dir(dirname):
         raise OSError, excs
 
 
-def remove_if_possible(f):
+def remove_if_possible(path):
+    #precondition_abspath(path)
+
     try:
-        remove(f)
+        remove(path)
     except:
         pass
 
 def du(basedir):
-    size = 0
+    #precondition_abspath(basedir)
 
+    size = 0
     for root, dirs, files in os.walk(basedir):
         for f in files:
             fn = os.path.join(root, f)
@@ -237,19 +240,26 @@ def du(basedir):
 def move_into_place(source, dest):
     """Atomically replace a file, or as near to it as the platform allows.
     The dest file may or may not exist."""
+    #precondition_abspath(source)
+    #precondition_abspath(dest)
+
     if "win32" in sys.platform.lower():
         remove_if_possible(dest)
     os.rename(source, dest)
 
 def write_atomically(target, contents, mode="b"):
-    f = open(target+".tmp", "w"+mode)
+    #precondition_abspath(target)
+
+    f = open(target + u".tmp", "w"+mode)
     try:
         f.write(contents)
     finally:
         f.close()
-    move_into_place(target+".tmp", target)
+    move_into_place(target + u".tmp", target)
 
 def write(path, data, mode="wb"):
+    #precondition_abspath(path)
+
     wf = open(path, mode)
     try:
         wf.write(data)
@@ -257,6 +267,8 @@ def write(path, data, mode="wb"):
         wf.close()
 
 def read(path):
+    #precondition_abspath(path)
+
     rf = open(path, "rb")
     try:
         return rf.read()