[Spice-commits] common/vdlog.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Nov 21 14:49:25 UTC 2019
common/vdlog.cpp | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
New commits:
commit 615cd463e01750ac24efd58ab5f709181cfa6a67
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Nov 18 10:40:47 2019 +0000
vdlog: Use _wstat64 instead of GetFileSize
This has different advantages:
- code is shorter and more readable;
- does not need to open the file and close;
- works on files bigger than 4gb.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index e2561e2..a484a07 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -46,14 +46,8 @@ VDLog* VDLog::get(TCHAR* path)
if (_log || !path) {
return _log;
}
- DWORD size = 0;
- HANDLE file = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (file != INVALID_HANDLE_VALUE) {
- size = GetFileSize(file, NULL);
- CloseHandle(file);
- }
- if (size != INVALID_FILE_SIZE && size > LOG_ROLL_SIZE) {
+ __stat64 buf;
+ if (_wstat64(path, &buf) == 0 && buf.st_size > LOG_ROLL_SIZE) {
TCHAR roll_path[MAX_PATH];
swprintf_s(roll_path, MAX_PATH, L"%s.1", path);
if (!MoveFileEx(path, roll_path, MOVEFILE_REPLACE_EXISTING)) {
More information about the Spice-commits
mailing list