Commit 20ed414d authored by Alexandre Julliard's avatar Alexandre Julliard

wininet: Store file time as a SYSTEMTIME instead of a Unix struct tm.

parent 0fbd5569
...@@ -94,7 +94,7 @@ typedef struct ...@@ -94,7 +94,7 @@ typedef struct
BOOL bIsDirectory; BOOL bIsDirectory;
LPWSTR lpszName; LPWSTR lpszName;
DWORD nSize; DWORD nSize;
struct tm tmLastModified; SYSTEMTIME tmLastModified;
unsigned short permissions; unsigned short permissions;
} FILEPROPERTIESW, *LPFILEPROPERTIESW; } FILEPROPERTIESW, *LPFILEPROPERTIESW;
...@@ -3386,9 +3386,7 @@ static BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFi ...@@ -3386,9 +3386,7 @@ static BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFi
if (lpafp) if (lpafp)
{ {
/* Convert 'Unix' time to Windows time */ SystemTimeToFileTime( &lpafp->tmLastModified, &lpFindFileData->ftLastAccessTime );
RtlSecondsSince1970ToTime(mktime(&lpafp->tmLastModified),
(LARGE_INTEGER *) &(lpFindFileData->ftLastAccessTime));
lpFindFileData->ftLastWriteTime = lpFindFileData->ftLastAccessTime; lpFindFileData->ftLastWriteTime = lpFindFileData->ftLastAccessTime;
lpFindFileData->ftCreationTime = lpFindFileData->ftLastAccessTime; lpFindFileData->ftCreationTime = lpFindFileData->ftLastAccessTime;
...@@ -3456,12 +3454,12 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT ...@@ -3456,12 +3454,12 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
lpfp->nSize = atol(pszToken); lpfp->nSize = atol(pszToken);
} }
lpfp->tmLastModified.tm_sec = 0; lpfp->tmLastModified.wSecond = 0;
lpfp->tmLastModified.tm_min = 0; lpfp->tmLastModified.wMinute = 0;
lpfp->tmLastModified.tm_hour = 0; lpfp->tmLastModified.wHour = 0;
lpfp->tmLastModified.tm_mday = 0; lpfp->tmLastModified.wDay = 0;
lpfp->tmLastModified.tm_mon = 0; lpfp->tmLastModified.wMonth = 0;
lpfp->tmLastModified.tm_year = 0; lpfp->tmLastModified.wYear = 0;
/* Determine month */ /* Determine month */
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
...@@ -3469,34 +3467,31 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT ...@@ -3469,34 +3467,31 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
if(strlen(pszToken) >= 3) { if(strlen(pszToken) >= 3) {
pszToken[3] = 0; pszToken[3] = 0;
if((pszTmp = StrStrIA(szMonths, pszToken))) if((pszTmp = StrStrIA(szMonths, pszToken)))
lpfp->tmLastModified.tm_mon = ((pszTmp - szMonths) / 3)+1; lpfp->tmLastModified.wMonth = ((pszTmp - szMonths) / 3)+1;
} }
/* Determine day */ /* Determine day */
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
if(!pszToken) continue; if(!pszToken) continue;
lpfp->tmLastModified.tm_mday = atoi(pszToken); lpfp->tmLastModified.wDay = atoi(pszToken);
/* Determine time or year */ /* Determine time or year */
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
if(!pszToken) continue; if(!pszToken) continue;
if((pszTmp = strchr(pszToken, ':'))) { if((pszTmp = strchr(pszToken, ':'))) {
struct tm* apTM; SYSTEMTIME curr_time;
time_t aTime;
*pszTmp = 0; *pszTmp = 0;
pszTmp++; pszTmp++;
lpfp->tmLastModified.tm_min = atoi(pszTmp); lpfp->tmLastModified.wMinute = atoi(pszTmp);
lpfp->tmLastModified.tm_hour = atoi(pszToken); lpfp->tmLastModified.wHour = atoi(pszToken);
time(&aTime); GetLocalTime( &curr_time );
apTM = localtime(&aTime); lpfp->tmLastModified.wYear = curr_time.wYear;
lpfp->tmLastModified.tm_year = apTM->tm_year;
} }
else { else {
lpfp->tmLastModified.tm_year = atoi(pszToken) - 1900; lpfp->tmLastModified.wYear = atoi(pszToken);
lpfp->tmLastModified.tm_hour = 12; lpfp->tmLastModified.wHour = 12;
} }
TRACE("Mod time: %02d:%02d:%02d %02d/%02d/%02d\n", TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
lpfp->tmLastModified.tm_hour, lpfp->tmLastModified.tm_min, lpfp->tmLastModified.tm_sec, lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
(lpfp->tmLastModified.tm_year >= 100) ? lpfp->tmLastModified.tm_year - 100 : lpfp->tmLastModified.tm_year, lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
lpfp->tmLastModified.tm_mon, lpfp->tmLastModified.tm_mday);
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
if(!pszToken) continue; if(!pszToken) continue;
...@@ -3509,32 +3504,31 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT ...@@ -3509,32 +3504,31 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
05-09-03 06:02PM 12656686 2003-04-21bgm_cmd_e.rgz 05-09-03 06:02PM 12656686 2003-04-21bgm_cmd_e.rgz
*/ */
else if(isdigit(pszToken[0]) && 8 == strlen(pszToken)) { else if(isdigit(pszToken[0]) && 8 == strlen(pszToken)) {
int mon, mday, year, hour, min;
lpfp->permissions = 0xFFFF; /* No idea, put full permission :-) */ lpfp->permissions = 0xFFFF; /* No idea, put full permission :-) */
sscanf(pszToken, "%d-%d-%d", sscanf(pszToken, "%d-%d-%d", &mon, &mday, &year);
&lpfp->tmLastModified.tm_mon, lpfp->tmLastModified.wDay = mday;
&lpfp->tmLastModified.tm_mday, lpfp->tmLastModified.wMonth = mon;
&lpfp->tmLastModified.tm_year); lpfp->tmLastModified.wYear = year;
/* Hacky and bad Y2K protection :-) */ /* Hacky and bad Y2K protection :-) */
if (lpfp->tmLastModified.tm_year < 70) if (lpfp->tmLastModified.wYear < 70) lpfp->tmLastModified.wYear += 2000;
lpfp->tmLastModified.tm_year += 100;
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
if(!pszToken) continue; if(!pszToken) continue;
sscanf(pszToken, "%d:%d", sscanf(pszToken, "%d:%d", &hour, &min);
&lpfp->tmLastModified.tm_hour, lpfp->tmLastModified.wHour = hour;
&lpfp->tmLastModified.tm_min); lpfp->tmLastModified.wMinute = min;
if((pszToken[5] == 'P') && (pszToken[6] == 'M')) { if((pszToken[5] == 'P') && (pszToken[6] == 'M')) {
lpfp->tmLastModified.tm_hour += 12; lpfp->tmLastModified.wHour += 12;
} }
lpfp->tmLastModified.tm_sec = 0; lpfp->tmLastModified.wSecond = 0;
TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
TRACE("Mod time: %02d:%02d:%02d %02d/%02d/%02d\n",
lpfp->tmLastModified.tm_hour, lpfp->tmLastModified.tm_min, lpfp->tmLastModified.tm_sec,
(lpfp->tmLastModified.tm_year >= 100) ? lpfp->tmLastModified.tm_year - 100 : lpfp->tmLastModified.tm_year,
lpfp->tmLastModified.tm_mon, lpfp->tmLastModified.tm_mday);
pszToken = strtok(NULL, szSpace); pszToken = strtok(NULL, szSpace);
if(!pszToken) continue; if(!pszToken) continue;
if(!strcasecmp(pszToken, "<DIR>")) { if(!strcasecmp(pszToken, "<DIR>")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment