aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2015-11-08 16:26:20 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2015-11-08 16:28:00 +0200
commit951c23f25708a0e39ed0fcaac1862fbc2fad178b (patch)
tree033d67fd971e8cecf2927c75df0a4c76770cbf4e /libtcc.c
parent37e815eee19996895398772b87249ecc3f6ff441 (diff)
downloadtinycc-951c23f25708a0e39ed0fcaac1862fbc2fad178b.tar.gz
tinycc-951c23f25708a0e39ed0fcaac1862fbc2fad178b.tar.bz2
win: include dirs: add some docs, minor refactor
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libtcc.c b/libtcc.c
index c11cd53..0ad2683 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1510,6 +1510,20 @@ LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val)
}
+/* Windows stat* ( https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx ):
+ * - st_gid, st_ino, st_uid: only valid on "unix" file systems (not FAT, NTFS, etc)
+ * - st_atime, st_ctime: not valid on FAT, valid on NTFS.
+ * - Other fields should be reasonably compatible (and S_ISDIR should work).
+ *
+ * BY_HANDLE_FILE_INFORMATION ( https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788%28v=vs.85%29.aspx ):
+ * - File index (combined nFileIndexHigh and nFileIndexLow) _may_ change when the file is opened.
+ * - But on NTFS: it's guaranteed to be the same value until the file is deleted.
+ * - On windows server 2012 there's a 128b file id, and the 64b one via
+ * nFileIndex* is not guaranteed to be unique.
+ *
+ * - MS Docs suggest to that volume number with the file index could be used to
+ * check if two handles refer to the same file.
+ */
#ifndef _WIN32
typedef struct stat file_info_t;
#else
@@ -1524,11 +1538,11 @@ int get_file_info(const char *fname, file_info_t *out_info)
int rv = 1;
HANDLE h = CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, NULL);
- if (h == INVALID_HANDLE_VALUE)
- return rv;
- rv = !GetFileInformationByHandle(h, out_info);
- CloseHandle(h);
+ if (h != INVALID_HANDLE_VALUE) {
+ rv = !GetFileInformationByHandle(h, out_info);
+ CloseHandle(h);
+ }
return rv;
#endif
}