diff --git a/ndir.c b/ndir.c index e1bda5f..46fb724 100644 --- a/ndir.c +++ b/ndir.c @@ -229,20 +229,6 @@ static int ndir_is_accepted_stub(char *s) return(0); } -static int ndir_path_is_dir(char *path) -{ - struct stat st; - - if (!path || !*path || tool_is_current_path(path)) - return(1); - - if (stat(path, &st) == 0) { - if (st.st_mode & S_IFDIR) - return(1); - } - - return(0); -} static void ndir_split_spec(char *spec, char *dir, char *pat) { @@ -252,7 +238,7 @@ static void ndir_split_spec(char *spec, char *dir, char *pat) return; } - if (!tool_has_wildcards(spec) && ndir_path_is_dir(spec)) { + if (!tool_has_wildcards(spec) && tool_path_is_dir(spec)) { strmaxcpy(dir, spec, 259); strmaxcpy(pat, "*.*", 259); return; diff --git a/net.h b/net.h index f3495c9..45e7b8f 100644 --- a/net.h +++ b/net.h @@ -160,6 +160,7 @@ extern int tool_current_dhandle(uint8 *connid, uint8 *dhandle); extern int tool_current_dhandle_only(uint8 *dhandle); extern int tool_current_prefix(char *out, int max); extern int tool_is_current_path(char *path); +extern int tool_path_is_dir(char *path); extern void tool_upcopy(char *dst, char *src, int max); extern void tool_basename(char *dst, char *src, int max); extern void tool_header_path(char *out, char *path, int max); diff --git a/remove.c b/remove.c index 18ad7dc..c5dafb6 100644 --- a/remove.c +++ b/remove.c @@ -148,7 +148,7 @@ static int remove_files(char *path, uint16 dhandle, uint32 object_id, char target[260]; int rc = 0; - if (trustee_path_is_dir(path)) { + if (tool_path_is_dir(path)) { strmaxcpy(dir, path, sizeof(dir) - 1); strmaxcpy(pat, "*.*", sizeof(pat) - 1); } else if (tool_has_wildcards(path)) { diff --git a/revoke.c b/revoke.c index 1e35b13..b9d78fb 100644 --- a/revoke.c +++ b/revoke.c @@ -187,7 +187,7 @@ static int revoke_files(char *path, uint16 dhandle, uint32 object_id, char target[260]; int rc = 0; - if (trustee_path_is_dir(path)) { + if (tool_path_is_dir(path)) { strmaxcpy(dir, path, sizeof(dir) - 1); strmaxcpy(pat, "*.*", sizeof(pat) - 1); } else if (tool_has_wildcards(path)) { diff --git a/tools.c b/tools.c index 0757c79..8c35f15 100644 --- a/tools.c +++ b/tools.c @@ -854,6 +854,34 @@ int tool_is_current_path(char *path) return(0); } +/* + * tool_path_is_dir + * + * Purpose: + * Tests whether a path should be treated as a directory. + * + * Parameters: + * path - DOS/NetWare path to test. + * + * Returns: + * Non-zero when the path is empty/current-directory syntax or stat() reports + * a directory, otherwise zero. + */ +int tool_path_is_dir(char *path) +{ + struct stat st; + + if (tool_is_current_path(path)) + return(1); + + if (stat(path, &st) == 0) { + if (st.st_mode & S_IFDIR) + return(1); + } + + return(0); +} + /* * tool_upcopy * diff --git a/trustee.c b/trustee.c index cbf6d36..4e5a41b 100644 --- a/trustee.c +++ b/trustee.c @@ -212,38 +212,4 @@ uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given) return(object_id); } -/* - * trustee_path_is_dir - * - * Purpose: - * Tests whether a path should be treated as a directory by the trustee - * commands. - * - * Parameters: - * path - DOS/NetWare path to test. - * - * Returns: - * Non-zero when the path is empty/current-directory syntax or stat() reports - * a directory, otherwise zero. - * - * Notes: - * This remains in trustee.c because the empty/current-directory handling is - * part of the GRANT/REMOVE/REVOKE trustee command semantics rather than a - * completely generic path predicate. - */ -int trustee_path_is_dir(char *path) -{ - struct stat st; - - if (!path || !*path || tool_strsame(path, ".") || tool_strsame(path, ".\\") || - tool_strsame(path, "./")) - return(1); - - if (stat(path, &st) == 0) { - if (st.st_mode & S_IFDIR) - return(1); - } - - return(0); -} diff --git a/trustee.h b/trustee.h index f2ba9c9..59c58e2 100644 --- a/trustee.h +++ b/trustee.h @@ -47,6 +47,5 @@ int trustee_parse_right_word(char *s, uint16 *rights); void trustee_rights_bracket(uint16 rights, char *out); void trustee_header_path(char *out, char *path, int max); uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given); -int trustee_path_is_dir(char *path); #endif