mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/win32-vd_agent
synced 2026-01-01 04:11:28 +00:00
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@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
parent
1dd3f3586a
commit
615cd463e0
@ -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)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user