Commit 635ba118 by Edward Thomson

is_empty_dir (wi32): cope with empty mount points

FindFirstFile will fail with INVALID_HANDLE_VALUE if there are no
children to the given path, which can happen if the given path is a
file (and obviously has no children) or if the given path is an empty
mount point.  (Most directories have at least directory entries '.'
and '..', but ridiculously another volume mounted in another drive
letter's path space do not, and thus have nothing to enumerate.)

If FindFirstFile fails, check if this is a directory-like thing
(a mount point).
parent b2fa95a0
...@@ -494,8 +494,19 @@ bool git_path_is_empty_dir(const char *path) ...@@ -494,8 +494,19 @@ bool git_path_is_empty_dir(const char *path)
WIN32_FIND_DATAW findData; WIN32_FIND_DATAW findData;
HANDLE hFind = FindFirstFileW(filter_w, &findData); HANDLE hFind = FindFirstFileW(filter_w, &findData);
/* FindFirstFile will fail if there are no children to the given
* path, which can happen if the given path is a file (and obviously
* has no children) or if the given path is an empty mount point.
* (Most directories have at least directory entries '.' and '..',
* but ridiculously another volume mounted in another drive letter's
* path space do not, and thus have nothing to enumerate.) If
* FindFirstFile fails, check if this is a directory-like thing
* (a mount point).
*/
if (hFind == INVALID_HANDLE_VALUE)
return git_path_isdir(path);
/* If the find handle was created successfully, then it's a directory */ /* If the find handle was created successfully, then it's a directory */
if (hFind != INVALID_HANDLE_VALUE) {
empty = true; empty = true;
do { do {
...@@ -511,7 +522,6 @@ bool git_path_is_empty_dir(const char *path) ...@@ -511,7 +522,6 @@ bool git_path_is_empty_dir(const char *path)
FindClose(hFind); FindClose(hFind);
} }
}
return empty; return empty;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment