diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/file_handling.h | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
Diffstat (limited to 'shared/file_handling.h')
-rw-r--r-- | shared/file_handling.h | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/shared/file_handling.h b/shared/file_handling.h index bdd73bea..f1ed2d98 100644 --- a/shared/file_handling.h +++ b/shared/file_handling.h @@ -33,52 +33,55 @@ enum ResponseSame }; ResponseSame onSameVolume(const Zstring& folderLeft, const Zstring& folderRight); //throw() -void checkthis(const Zstring& folderLeft); //throw() +enum ProcSymlink +{ + SYMLINK_DIRECT, + SYMLINK_FOLLOW +}; -//copy file or directory create/last change date, -void copyFileTimes(const Zstring& sourceDir, const Zstring& targetDir, bool derefSymlinks); //throw (FileError) +Int64 getFileTime(const Zstring& filename, ProcSymlink procSl); //throw FileError +void setFileTime(const Zstring& filename, const Int64& modificationTime, ProcSymlink procSl); //throw FileError //symlink handling: always evaluate target -UInt64 getFilesize(const Zstring& filename); //throw (FileError) - +UInt64 getFilesize(const Zstring& filename); //throw FileError //file handling bool removeFile(const Zstring& filename); //return "true" if file was actually deleted; throw (FileError) -void removeDirectory(const Zstring& directory, CallbackRemoveDir* callback = NULL); //throw (FileError) +void removeDirectory(const Zstring& directory, CallbackRemoveDir* callback = NULL); //throw FileError //rename file or directory: no copying!!! -void renameFile(const Zstring& oldName, const Zstring& newName); //throw (FileError); +void renameFile(const Zstring& oldName, const Zstring& newName); //throw FileError; //move source to target; expectations: all super-directories of target exist //"ignoreExisting": if target already exists, source is deleted -void moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback); //throw (FileError); +void moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback); //throw FileError; //move source to target including subdirectories //"ignoreExisting": existing directories and files will be enriched -void moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback); //throw (FileError); +void moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback); //throw FileError; //creates superdirectories automatically: -void createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions); //throw (FileError); -void createDirectory(const Zstring& directory); //throw (FileError); -> function overload avoids default parameter ambiguity issues! +void createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions); //throw FileError; +void createDirectory(const Zstring& directory); //throw FileError; -> function overload avoids default parameter ambiguity issues! +struct FileAttrib +{ + UInt64 fileSize; + Int64 modificationTime; //size_t UTC compatible +}; -void copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPathMissing, ErrorFileLocked (Windows-only)); - const Zstring& targetFile, +void copyFile(const Zstring& sourceFile, //throw FileError, ErrorTargetPathMissing, ErrorFileLocked (Windows-only) + const Zstring& targetFile, //symlink handling: dereference source bool copyFilePermissions, bool transactionalCopy, - CallbackCopyFile* callback); //may be NULL + CallbackCopyFile* callback, //may be NULL + FileAttrib* sourceAttr = NULL); //return current attributes at the time of copy //Note: it MAY happen that copyFile() leaves temp files behind, e.g. temporary network drop. // => clean them up at an appropriate time (automatically set sync directions to delete them). They have the following ending: const Zstring TEMP_FILE_ENDING = Zstr(".ffs_tmp"); -enum SymlinkType -{ - SYMLINK_TYPE_FILE, - SYMLINK_TYPE_DIR -}; -void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, SymlinkType type, bool copyFilePermissions); //throw (FileError) - +void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, bool copyFilePermissions); //throw FileError @@ -87,7 +90,8 @@ void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, SymlinkTy struct CallbackRemoveDir { virtual ~CallbackRemoveDir() {} - virtual void notifyDeletion(const Zstring& currentObject) = 0; + virtual void notifyFileDeletion(const Zstring& filename) = 0; + virtual void notifyDirDeletion(const Zstring& dirname) = 0; }; @@ -101,7 +105,7 @@ struct CallbackCopyFile //callback functionality //may throw: //Linux: unconditionally - //Windows: first exception is swallowed, requestUiRefresh() is then called again where it may throw again and exception will propagate as expected + //Windows: first exception is swallowed, requestUiRefresh() is then called again where it should throw again and exception will propagate as expected virtual void updateCopyStatus(UInt64 totalBytesTransferred) = 0; }; |