Skip to content

Commit

Permalink
Fix Windows Alternate Data Stream (ADS) Support
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellandau authored and nmoinvaz committed Jan 8, 2025
1 parent cf5404b commit 4a1d10f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions mz_os_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ static void mz_os_unix_to_file_time(time_t unix_time, FILETIME *file_time) {
}

int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date) {
WIN32_FIND_DATAW ff32;
HANDLE handle = NULL;
WIN32_FILE_ATTRIBUTE_DATA wfad;
wchar_t *path_wide = NULL;
int32_t err = MZ_INTERNAL_ERROR;

Expand All @@ -245,21 +244,19 @@ int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *acc
if (!path_wide)
return MZ_PARAM_ERROR;

handle = FindFirstFileW(path_wide, &ff32);
free(path_wide);

if (handle != INVALID_HANDLE_VALUE) {
if (GetFileAttributesExW(path_wide, GetFileExInfoStandard, &wfad)) {
if (modified_date)
mz_os_file_to_unix_time(ff32.ftLastWriteTime, modified_date);
mz_os_file_to_unix_time(wfad.ftLastWriteTime, modified_date);
if (accessed_date)
mz_os_file_to_unix_time(ff32.ftLastAccessTime, accessed_date);
mz_os_file_to_unix_time(wfad.ftLastAccessTime, accessed_date);
if (creation_date)
mz_os_file_to_unix_time(ff32.ftCreationTime, creation_date);
mz_os_file_to_unix_time(wfad.ftCreationTime, creation_date);

FindClose(handle);
err = MZ_OK;
}

free(path_wide);

return err;
}

Expand Down

0 comments on commit 4a1d10f

Please sign in to comment.