Unified · Split
| @@ -1510,6 +1510,20 @@ LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val) · 1509 unmodified lines | ||
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | 1512 | |
| 1513 | +/* Windows stat* ( https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx ): | |
| 1514 | + * - st_gid, st_ino, st_uid: only valid on "unix" file systems (not FAT, NTFS, etc) | |
| 1515 | + * - st_atime, st_ctime: not valid on FAT, valid on NTFS. | |
| 1516 | + * - Other fields should be reasonably compatible (and S_ISDIR should work). | |
| 1517 | + * | |
| 1518 | + * BY_HANDLE_FILE_INFORMATION ( https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788%28v=vs.85%29.aspx ): | |
| 1519 | + * - File index (combined nFileIndexHigh and nFileIndexLow) _may_ change when the file is opened. | |
| 1520 | + * - But on NTFS: it's guaranteed to be the same value until the file is deleted. | |
| 1521 | + * - On windows server 2012 there's a 128b file id, and the 64b one via | |
| 1522 | + * nFileIndex* is not guaranteed to be unique. | |
| 1523 | + * | |
| 1524 | + * - MS Docs suggest to that volume number with the file index could be used to | |
| 1525 | + * check if two handles refer to the same file. | |
| 1526 | + */ | |
| 1513 | 1527 | #ifndef _WIN32 |
| 1514 | 1528 | typedef struct stat file_info_t; |
| 1515 | 1529 | #else |
| @@ -1524,11 +1538,11 @@ int get_file_info(const char *fname, file_info_t *out_info) · 8 unmodified lines | ||
| 1524 | 1538 | int rv = 1; |
| 1525 | 1539 | HANDLE h = CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, |
| 1526 | 1540 | FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, NULL); |
| 1527 | − if (h == INVALID_HANDLE_VALUE) | |
| 1528 | − return rv; | |
| 1529 | 1541 | |
| 1530 | − rv = !GetFileInformationByHandle(h, out_info); | |
| 1531 | − CloseHandle(h); | |
| 1542 | + if (h != INVALID_HANDLE_VALUE) { | |
| 1543 | + rv = !GetFileInformationByHandle(h, out_info); | |
| 1544 | + CloseHandle(h); | |
| 1545 | + } | |
| 1532 | 1546 | return rv; |
| 1533 | 1547 | #endif |
| 1534 | 1548 | } |