dosutils: use shared path helper predicates
Replace small local path predicate wrappers with the shared tools.c helpers. NDIR now uses tool_is_dot_dir() directly and NCOPY uses tool_has_wildcards() for wildcard checks. More behavior-sensitive NCOPY path helpers are left local for now to avoid changing path normalization or default handling while NCOPY remains under investigation.
This commit is contained in:
9
ncopy.c
9
ncopy.c
@@ -190,11 +190,6 @@ static int ncopy_is_dir(char *path)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int ncopy_has_wildcards(char *s)
|
||||
{
|
||||
return(s && (strchr(s, '*') || strchr(s, '?')));
|
||||
}
|
||||
|
||||
static void ncopy_parent_pattern(char *dir, char *pat, char *path)
|
||||
{
|
||||
tool_parent_pattern(dir, pat, path, 260, 260);
|
||||
@@ -1691,13 +1686,13 @@ int func_ncopy(int argc, char *argv[], int mode)
|
||||
|
||||
ncopy_reset_output_group();
|
||||
|
||||
if (ncopy_has_wildcards(src) || (options & NCOPY_OPT_S)) {
|
||||
if (tool_has_wildcards(src) || (options & NCOPY_OPT_S)) {
|
||||
if (!ncopy_is_dir(dst)) {
|
||||
fprintf(stdout, " Illegal destination.\n");
|
||||
ncopy_summary(0, 0);
|
||||
return(1);
|
||||
}
|
||||
if ((options & NCOPY_OPT_S) && ncopy_is_dir(src) && !ncopy_has_wildcards(src)) {
|
||||
if ((options & NCOPY_OPT_S) && ncopy_is_dir(src) && !tool_has_wildcards(src)) {
|
||||
/* Novell NCOPY accepts a directory as the source root with /S. */
|
||||
strmaxcpy(srcdir, src, sizeof(srcdir) - 1);
|
||||
strmaxcpy(pat, "*.*", sizeof(pat) - 1);
|
||||
|
||||
14
ndir.c
14
ndir.c
@@ -646,14 +646,6 @@ static void ndir_effective_rights(char *path, char *out)
|
||||
}
|
||||
}
|
||||
|
||||
static int ndir_is_dot_dir(char *name)
|
||||
{
|
||||
if (!name) return(0);
|
||||
if (name[0] == '.' && name[1] == '\0') return(1);
|
||||
if (name[0] == '.' && name[1] == '.' && name[2] == '\0') return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void ndir_print_file(char *dir, NDIR_FIND_ENTRY *ent, int options,
|
||||
int *line_count, int *continuous)
|
||||
{
|
||||
@@ -796,7 +788,7 @@ static int ndir_collect_entries(char *dir, char *search, int want_dirs,
|
||||
_A_SYSTEM | _A_ARCH | _A_SUBDIR, &ff);
|
||||
while (rc == 0 && count < max_entries) {
|
||||
if (!!(ff.attrib & _A_SUBDIR) == !!want_dirs) {
|
||||
if (!want_dirs || !ndir_is_dot_dir(ff.name)) {
|
||||
if (!want_dirs || !tool_is_dot_dir(ff.name)) {
|
||||
list[count].ff = ff;
|
||||
ndir_fill_entry_info(dir, &list[count]);
|
||||
if (want_dirs) {
|
||||
@@ -1048,7 +1040,7 @@ static int ndir_spec_has_output(char *spec, int options)
|
||||
_A_SYSTEM | _A_ARCH | _A_SUBDIR, &ff);
|
||||
while (rc == 0) {
|
||||
if (ff.attrib & _A_SUBDIR) {
|
||||
if (!ndir_is_dot_dir(ff.name) && !(options & NDIR_OPT_FILES_ONLY))
|
||||
if (!tool_is_dot_dir(ff.name) && !(options & NDIR_OPT_FILES_ONLY))
|
||||
return(1);
|
||||
} else {
|
||||
if (!(options & NDIR_OPT_DIRS_ONLY))
|
||||
@@ -1078,7 +1070,7 @@ static int ndir_list_subdirs(char *dir, char *pattern, int options,
|
||||
rc = _dos_findfirst(search, _A_NORMAL | _A_RDONLY | _A_HIDDEN |
|
||||
_A_SYSTEM | _A_ARCH | _A_SUBDIR, &ff);
|
||||
while (rc == 0) {
|
||||
if ((ff.attrib & _A_SUBDIR) && !ndir_is_dot_dir(ff.name)) {
|
||||
if ((ff.attrib & _A_SUBDIR) && !tool_is_dot_dir(ff.name)) {
|
||||
tool_join_path(subdir, dir, ff.name, sizeof(subdir));
|
||||
tool_join_path(subspec, subdir, pattern, sizeof(subspec));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user