summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-05-27 11:30:51 +0000
committerTed Trask <ttrask01@yahoo.com>2009-05-27 11:30:51 +0000
commit9509dd4d07458af65e03b3487a11dff2bb053976 (patch)
tree6739c1a70031a39f06c4bd4065956b03e669b5ef
parent9b934599d84f0b3dd32cda657790dc2c34bd95d8 (diff)
downloadacf-core-9509dd4d07458af65e03b3487a11dff2bb053976.tar.bz2
acf-core-9509dd4d07458af65e03b3487a11dff2bb053976.tar.xz
Modified copy_file and move_file to overwrite existing file, only fail if existing directory.
-rw-r--r--lib/fs.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/fs.lua b/lib/fs.lua
index 962326c..872e62a 100644
--- a/lib/fs.lua
+++ b/lib/fs.lua
@@ -78,9 +78,9 @@ function create_file ( path )
end
-- Copies a file to a directory or new filename (creating the directory if necessary)
--- fails if new file already exists
+-- fails if new file is already a directory
function copy_file(oldpath, newpath)
- if not is_file(oldpath) or not newpath or newpath == "" or (basename(newpath) ~= "" and posix.stat(newpath)) or (basename(newpath) == "" and posix.stat(newpath .. basename(oldpath))) then
+ if not is_file(oldpath) or not newpath or newpath == "" or (basename(newpath) ~= "" and is_dir(newpath)) or (basename(newpath) == "" and is_dir(newpath .. basename(oldpath))) then
return false
end
if dirname(newpath) and not posix.stat(dirname(newpath)) then create_directory(dirname(newpath)) end
@@ -94,9 +94,9 @@ function copy_file(oldpath, newpath)
end
-- Moves a file to a directory or new filename (creating the directory if necessary)
--- fails if new file already exists
+-- fails if new file is already a directory
function move_file(oldpath, newpath)
- if not is_file(oldpath) or not newpath or newpath == "" or (basename(newpath) ~= "" and posix.stat(newpath)) or (basename(newpath) == "" and posix.stat(newpath .. basename(oldpath))) then
+ if not is_file(oldpath) or not newpath or newpath == "" or (basename(newpath) ~= "" and is_dir(newpath)) or (basename(newpath) == "" and is_dir(newpath .. basename(oldpath))) then
return false
end
if dirname(newpath) and not posix.stat(dirname(newpath)) then create_directory(dirname(newpath)) end