diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-02-23 09:27:20 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-02-23 09:27:20 +0000 |
commit | cad408ec98e566da75775bfc735b260e9adeec8c (patch) | |
tree | 6d7bf97bdcdc536f087604fbbc916774ec23cbf9 /lib/fs.lua | |
parent | b2b8ac87e45257215fa9642858a3bc5903b160e6 (diff) | |
download | acf-core-cad408ec98e566da75775bfc735b260e9adeec8c.tar.bz2 acf-core-cad408ec98e566da75775bfc735b260e9adeec8c.tar.xz |
Added fs.copy_properties and fixed fs.copy_file and modelfunction.write_file_with_audit to keep file properties.
Diffstat (limited to 'lib/fs.lua')
-rw-r--r-- | lib/fs.lua | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -77,6 +77,17 @@ function create_file ( path ) return is_file(path) end +-- Copies the permissions and ownership of one file to another (if they exist and are the same type) +function copy_properties(source, dest) + if posix.stat(source or "", "type") == posix.stat(dest or "", "type") then + local stats = posix.stat(source) + posix.chmod(dest, stats.mode) + posix.chown(dest, stats.uid, stats.gid) + return true + end + return false +end + -- Copies a file to a directory or new filename (creating the directory if necessary) -- fails if new file is already a directory function copy_file(oldpath, newpath) @@ -90,6 +101,7 @@ function copy_file(oldpath, newpath) new:write(old:read("*a")) new:close() old:close() + copy_properties(oldpath, newpath) return is_file(newpath) end |