summaryrefslogtreecommitdiff
path: root/zen/file_access.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-03-03 01:18:05 +0000
committerB Stack <bgstack15@gmail.com>2021-03-03 01:18:05 +0000
commit320f1ae680d73da35a0cfe4846eb687d8616bcac (patch)
tree6fb17404841b30822a2d9204e3e0932e55f05ebb /zen/file_access.h
parentMerge branch '11.6' into 'master' (diff)
parentadd upstream 11.7 (diff)
downloadFreeFileSync-320f1ae680d73da35a0cfe4846eb687d8616bcac.tar.gz
FreeFileSync-320f1ae680d73da35a0cfe4846eb687d8616bcac.tar.bz2
FreeFileSync-320f1ae680d73da35a0cfe4846eb687d8616bcac.zip
Merge branch '11.7' into 'master'11.7
add upstream 11.7 See merge request opensource-tracking/FreeFileSync!31
Diffstat (limited to 'zen/file_access.h')
-rw-r--r--zen/file_access.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/zen/file_access.h b/zen/file_access.h
index a3fa56d7..f3ea6c00 100644
--- a/zen/file_access.h
+++ b/zen/file_access.h
@@ -10,9 +10,8 @@
#include <functional>
#include "zstring.h"
#include "file_error.h"
-#include "file_id_def.h"
-#include "serialize.h"
-
+#include "serialize.h" //IoCallback
+ #include <sys/stat.h>
namespace zen
{
@@ -31,6 +30,21 @@ std::optional<Zstring> getParentFolderPath(const Zstring& itemPath);
bool fileAvailable(const Zstring& filePath); //noexcept
bool dirAvailable (const Zstring& dirPath ); //
+//FAT/FAT32: "Why does the timestamp of a file *increase* by up to 2 seconds when I copy it to a USB thumb drive?"
+const int FAT_FILE_TIME_PRECISION_SEC = 2; //https://devblogs.microsoft.com/oldnewthing/?p=83
+//https://web.archive.org/web/20141127143832/http://support.microsoft.com/kb/127830
+
+using FileIndex = ino_t;
+using FileTimeNative = timespec;
+
+inline time_t nativeFileTimeToTimeT(const timespec& ft) { return ft.tv_sec; } //follow Windows Explorer and always round down!
+inline timespec timetToNativeFileTime(time_t utcTime)
+{
+ timespec natTime = {};
+ natTime.tv_sec = utcTime;
+ return natTime;
+}
+
enum class ItemType
{
file,
@@ -47,14 +61,13 @@ std::optional<ItemType> itemStillExists(const Zstring& itemPath); //throw FileEr
enum class ProcSymlink
{
- DIRECT,
- FOLLOW
+ direct,
+ follow
};
void setFileTime(const Zstring& filePath, time_t modTime, ProcSymlink procSl); //throw FileError
//symlink handling: follow
int64_t getFreeDiskSpace(const Zstring& path); //throw FileError, returns < 0 if not available
-VolumeId getVolumeId(const Zstring& itemPath); //throw FileError
uint64_t getFileSize(const Zstring& filePath); //throw FileError
//get per-user directory designated for temporary files:
@@ -87,16 +100,15 @@ void copySymlink(const Zstring& sourcePath, const Zstring& targetPath); //throw
struct FileCopyResult
{
uint64_t fileSize = 0;
- time_t modTime = 0; //number of seconds since Jan. 1st 1970 UTC
- FileId sourceFileId;
- FileId targetFileId;
+ FileTimeNative sourceModTime = {};
+ FileIndex sourceFileIdx = 0;
+ FileIndex targetFileIdx = 0;
std::optional<FileError> errorModTime; //failure to set modification time
};
FileCopyResult copyNewFile(const Zstring& sourceFile, const Zstring& targetFile, //throw FileError, ErrorTargetExisting, ErrorFileLocked, X
//accummulated delta != file size! consider ADS, sparse, compressed files
- const IOCallback& notifyUnbufferedIO /*throw X*/);
-
+ const IoCallback& notifyUnbufferedIO /*throw X*/);
}
#endif //FILE_ACCESS_H_8017341345614857
bgstack15