diff options
| author | Ted Trask <ttrask01@yahoo.com> | 2009-06-22 12:23:56 +0000 |
|---|---|---|
| committer | Ted Trask <ttrask01@yahoo.com> | 2009-06-22 12:23:56 +0000 |
| commit | 18a1ac4eebf8ea4ae71b9b471bd1bb8e294dc697 (patch) | |
| tree | 53e3bece0c51217a340b6c286f883a4be15a8576 /lib | |
| parent | 57a83de2ca3a1e41d8d55c1a8e8237277d4e2386 (diff) | |
| download | acf-core-18a1ac4eebf8ea4ae71b9b471bd1bb8e294dc697.tar.bz2 acf-core-18a1ac4eebf8ea4ae71b9b471bd1bb8e294dc697.tar.xz | |
Modified copy_file and move_file to overwrite existing file, only fail if existing directory.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fs.lua | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 |
