From 9389a7c7a13deafed12641c1237a800186455c73 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 25 Nov 2025 01:43:28 +0000 Subject: [PATCH] fix git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@804 b9cfdab3-6d41-4d17-bbe4-086880011989 --- src/abstract/directory.c | 5 +++++ src/string.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/abstract/directory.c b/src/abstract/directory.c index 16376fb..e468aed 100644 --- a/src/abstract/directory.c +++ b/src/abstract/directory.c @@ -54,6 +54,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { dir_t* dir = handle; MwDirectoryEntry* entry = malloc(sizeof(*entry)); #ifdef _WIN32 + ULARGE_INTEGER* l; if(dir->first) { dir->first = 0; } else if(FindNextFile(dir->hFind, &dir->ffd) == 0) { @@ -73,6 +74,10 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { entry->size |= dir->ffd.nFileSizeHigh; entry->size = entry->size << 32; entry->size |= dir->ffd.nFileSizeLow; + + l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime; + + entry->mtime = l->QuadPart / 10000000 - 11644473600; #else struct dirent* d; struct stat s; diff --git a/src/string.c b/src/string.c index 7835d50..9f12010 100644 --- a/src/string.c +++ b/src/string.c @@ -32,5 +32,9 @@ void MwStringTime(char* out, time_t t) { struct tm* tm = localtime(&t); const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year); + if(tm == NULL) { + sprintf(out, "localtime error"); + } else { + sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year); + } }