diff options
author | Jan Dubois <jand@activestate.com> | 2006-02-21 04:36:31 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-02-23 14:07:13 +0000 |
commit | cba61fe146f58b7c23f03d55e645ba7b4552bb7e (patch) | |
tree | fdb82ef2c0a760cae5653d3fb32a9d2b992982d6 /win32 | |
parent | ff920335f21fa0dd5c981a4f17dee5ac5ad41b6b (diff) | |
download | perl-cba61fe146f58b7c23f03d55e645ba7b4552bb7e.tar.gz |
Implement ${^WIN32_SLOPPY_STAT}
From: "Jan Dubois" <jand@ActiveState.com>
Message-ID: <019601c63726$7fcca200$6062a8c0@candy>
p4raw-id: //depot/perl@27283
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/win32/win32.c b/win32/win32.c index 41b7045499..0f67ba12fb 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1167,10 +1167,13 @@ win32_stat(const char *path, Stat_t *sbuf) char buffer[MAX_PATH+1]; int l = strlen(path); int res; - HANDLE handle; int nlink = 1; BOOL expect_dir = FALSE; + GV *gv_sloppy = gv_fetchpvs("\027IN32_SLOPPY_STAT", + GV_NOTQUAL, SVt_PV); + BOOL sloppy = gv_sloppy && SvTRUE(GvSV(gv_sloppy)); + if (l > 1) { switch(path[l - 1]) { /* FindFirstFile() and stat() are buggy with a trailing @@ -1208,17 +1211,20 @@ win32_stat(const char *path, Stat_t *sbuf) } } - /* We *must* open & close the file once; otherwise file attribute changes */ - /* might not yet have propagated to "other" hard links of the same file. */ - /* This also gives us an opportunity to determine the number of links. */ path = PerlDir_mapA(path); l = strlen(path); - handle = CreateFileA(path, 0, 0, NULL, OPEN_EXISTING, 0, NULL); - if (handle != INVALID_HANDLE_VALUE) { - BY_HANDLE_FILE_INFORMATION bhi; - if (GetFileInformationByHandle(handle, &bhi)) - nlink = bhi.nNumberOfLinks; - CloseHandle(handle); + + if (!sloppy) { + /* We must open & close the file once; otherwise file attribute changes */ + /* might not yet have propagated to "other" hard links of the same file. */ + /* This also gives us an opportunity to determine the number of links. */ + HANDLE handle = CreateFileA(path, 0, 0, NULL, OPEN_EXISTING, 0, NULL); + if (handle != INVALID_HANDLE_VALUE) { + BY_HANDLE_FILE_INFORMATION bhi; + if (GetFileInformationByHandle(handle, &bhi)) + nlink = bhi.nNumberOfLinks; + CloseHandle(handle); + } } /* path will be mapped correctly above */ |