diff options
| author | Hunter <lh563566994@126.com> | 2018-10-13 01:29:11 +0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-10-12 10:29:11 -0700 |
| commit | cee9c53a51cdbd7d3f9a8395de37570be5687db8 (patch) | |
| tree | ebc7aac5e918c5ed4174cbcecacd395485676213 /src | |
| parent | 617bb5112834eee40d7eaf00bfc7e98e0ae1ff01 (diff) | |
| download | nng-cee9c53a51cdbd7d3f9a8395de37570be5687db8.tar.gz nng-cee9c53a51cdbd7d3f9a8395de37570be5687db8.tar.bz2 nng-cee9c53a51cdbd7d3f9a8395de37570be5687db8.zip | |
Fix win file type (#749)
before: nni_file_is_dir with path D:\\ D:/ D: all returns false
after: nni_file_is_dir with path D:\\ D:/ D: all returns true
Diffstat (limited to 'src')
| -rw-r--r-- | src/platform/windows/win_file.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/platform/windows/win_file.c b/src/platform/windows/win_file.c index 47bb87af..4fc5930f 100644 --- a/src/platform/windows/win_file.c +++ b/src/platform/windows/win_file.c @@ -1,6 +1,7 @@ // // Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> +// Copyright 2018 QXSoftware <lh563566994@126.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -281,18 +282,16 @@ nni_plat_temp_dir(void) int nni_plat_file_type(const char *name, int *typep) { - HANDLE dirh; - WIN32_FIND_DATA data; + DWORD attrs; - if ((dirh = FindFirstFile(name, &data)) == INVALID_HANDLE_VALUE) { + if ((attrs = GetFileAttributes(name)) == INVALID_FILE_ATTRIBUTES) { return (nni_win_error(GetLastError())); } - (void) FindClose(dirh); - if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (attrs & FILE_ATTRIBUTE_DIRECTORY) { *typep = NNI_PLAT_FILE_TYPE_DIR; - } else if (data.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) { + } else if (attrs & FILE_ATTRIBUTE_DEVICE) { *typep = NNI_PLAT_FILE_TYPE_OTHER; - } else if (data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { + } else if (attrs & FILE_ATTRIBUTE_HIDDEN) { *typep = NNI_PLAT_FILE_TYPE_OTHER; } else { *typep = NNI_PLAT_FILE_TYPE_FILE; |
