Skip to content

Commit 92fcaf1

Browse files
committed
Changed the use of localtime_r() to localtime() for better portability. Allows ps2client to be compiled under MinGW.
1 parent 713b3f7 commit 92fcaf1

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/ps2link.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@
468468
int ps2link_request_readdir(void *packet) {
469469
DIR *dir;
470470
struct { unsigned int number; unsigned short length; int dd; } PACKED *request = packet;
471-
struct dirent *dirent; struct stat stats; struct tm loctime;
471+
struct dirent *dirent; struct stat stats; struct tm *loctime;
472472
unsigned int mode; unsigned char ctime[8]; unsigned char atime[8]; unsigned char mtime[8];
473473
char tname[512];
474474

@@ -500,31 +500,31 @@
500500
if (S_ISREG(stats.st_mode)) { mode |= 0x10; }
501501

502502
// Convert the creation time.
503-
localtime_r(&(stats.st_ctime), &loctime);
504-
ctime[6] = (unsigned char)loctime.tm_year;
505-
ctime[5] = (unsigned char)loctime.tm_mon + 1;
506-
ctime[4] = (unsigned char)loctime.tm_mday;
507-
ctime[3] = (unsigned char)loctime.tm_hour;
508-
ctime[2] = (unsigned char)loctime.tm_min;
509-
ctime[1] = (unsigned char)loctime.tm_sec;
503+
loctime = localtime(&(stats.st_ctime));
504+
ctime[6] = (unsigned char)loctime->tm_year;
505+
ctime[5] = (unsigned char)loctime->tm_mon + 1;
506+
ctime[4] = (unsigned char)loctime->tm_mday;
507+
ctime[3] = (unsigned char)loctime->tm_hour;
508+
ctime[2] = (unsigned char)loctime->tm_min;
509+
ctime[1] = (unsigned char)loctime->tm_sec;
510510

511511
// Convert the access time.
512-
localtime_r(&(stats.st_atime), &loctime);
513-
atime[6] = (unsigned char)loctime.tm_year;
514-
atime[5] = (unsigned char)loctime.tm_mon + 1;
515-
atime[4] = (unsigned char)loctime.tm_mday;
516-
atime[3] = (unsigned char)loctime.tm_hour;
517-
atime[2] = (unsigned char)loctime.tm_min;
518-
atime[1] = (unsigned char)loctime.tm_sec;
512+
loctime = localtime(&(stats.st_atime));
513+
atime[6] = (unsigned char)loctime->tm_year;
514+
atime[5] = (unsigned char)loctime->tm_mon + 1;
515+
atime[4] = (unsigned char)loctime->tm_mday;
516+
atime[3] = (unsigned char)loctime->tm_hour;
517+
atime[2] = (unsigned char)loctime->tm_min;
518+
atime[1] = (unsigned char)loctime->tm_sec;
519519

520520
// Convert the last modified time.
521-
localtime_r(&(stats.st_mtime), &loctime);
522-
mtime[6] = (unsigned char)loctime.tm_year;
523-
mtime[5] = (unsigned char)loctime.tm_mon + 1;
524-
mtime[4] = (unsigned char)loctime.tm_mday;
525-
mtime[3] = (unsigned char)loctime.tm_hour;
526-
mtime[2] = (unsigned char)loctime.tm_min;
527-
mtime[1] = (unsigned char)loctime.tm_sec;
521+
loctime = localtime(&(stats.st_mtime));
522+
mtime[6] = (unsigned char)loctime->tm_year;
523+
mtime[5] = (unsigned char)loctime->tm_mon + 1;
524+
mtime[4] = (unsigned char)loctime->tm_mday;
525+
mtime[3] = (unsigned char)loctime->tm_hour;
526+
mtime[2] = (unsigned char)loctime->tm_min;
527+
mtime[1] = (unsigned char)loctime->tm_sec;
528528

529529
// Send the response.
530530
return ps2link_response_readdir(1, mode, 0, stats.st_size, ctime, atime, mtime, 0, dirent->d_name);

0 commit comments

Comments
 (0)