summaryrefslogtreecommitdiff
path: root/lib/ftools.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ftools.rb')
-rw-r--r--lib/ftools.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ftools.rb b/lib/ftools.rb
index 103e27a..7bba07e 100644
--- a/lib/ftools.rb
+++ b/lib/ftools.rb
@@ -24,6 +24,9 @@ class << File
fsize = 1024 if fsize < 512
fsize = TOO_BIG if fsize > TOO_BIG
+ fmode = stat(from).mode
+ tpath = to
+
from = open(from, "r")
from.binmode
to = open(to, "w")
@@ -47,6 +50,7 @@ class << File
to.close
from.close
end
+ chmod(fmode, tpath)
ret
end
@@ -66,10 +70,17 @@ class << File
if PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to
unlink to
end
+ fstat = stat(from)
begin
rename from, to
rescue
+ from_stat = stat(from)
syscopy from, to and unlink from
+ utime(from_stat.atime, from_stat.mtime, to)
+ begin
+ chown(fstat.uid, fstat.gid, tpath)
+ rescue
+ end
end
end