commit a5d47be5adc7c493ff7e87fc47241a84e268a3f0 (tree)
parent d5860cbade79141c4c547a3411befb8448dd56ab
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 16 Feb 2020 22:49:28 -0500
stage1 os_update_file additionally compares src and dest size
prevents problems when source is created and then immediately copied to
dest.
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/os.cpp b/src/os.cpp
@@ -1108,9 +1108,10 @@ Error os_update_file(Buf *src_path, Buf *dst_path) {
return err;
}
- if (src_attr.mtime.sec == dst_attr.mtime.sec &&
- src_attr.mtime.nsec == dst_attr.mtime.nsec &&
- src_attr.mode == dst_attr.mode)
+ if (src_attr.size == dst_attr.size &&
+ src_attr.mode == dst_attr.mode &&
+ src_attr.mtime.sec == dst_attr.mtime.sec &&
+ src_attr.mtime.nsec == dst_attr.mtime.nsec)
{
os_file_close(&src_file);
os_file_close(&dst_file);
@@ -1871,6 +1872,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
windows_filetime_to_os_timestamp(&file_info.ftLastWriteTime, &attr->mtime);
attr->inode = (((uint64_t)file_info.nFileIndexHigh) << 32) | file_info.nFileIndexLow;
attr->mode = 0;
+ attr->size = (((uint64_t)file_info.nFileSizeHigh) << 32) | file_info.nFileSizeLow;
}
return ErrorNone;
@@ -1918,6 +1920,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
attr->mtime.nsec = statbuf.st_mtim.tv_nsec;
#endif
attr->mode = statbuf.st_mode;
+ attr->size = statbuf.st_size;
}
return ErrorNone;
}
diff --git a/src/os.hpp b/src/os.hpp
@@ -99,6 +99,7 @@ struct OsTimeStamp {
struct OsFileAttr {
OsTimeStamp mtime;
+ uint64_t size;
uint64_t inode;
uint32_t mode;
};