📄 mapname.c
字号:
}
#ifdef NO_MKDIR
sprintf(command,
"IFS=\" \t\n\" /bin/mkdir %s 2>/dev/null", cdp);
if (system(command)) {
#else /* !NO_MKDIR */
if (MKDIR(cdp, PERMS) == -1) {
#endif /* ?NO_MKDIR */
perror(cdp);
free(cdp);
fprintf(stderr, "mapame: unable to process [%s]\n",
filename);
return 3;
}
created = TRUE;
#ifdef OS2
if (longdir)
SetLongNameEA(cdp, longfilename);
#endif /* OS2 */
} else if (!(statbuf.st_mode & S_IFDIR)) {
fprintf(stderr,
"mapname: %s exists but is not a directory\n", cdp);
free(cdp);
fprintf(stderr, "mapame: unable to process [%s]\n",
filename);
return 3;
}
#ifdef VMS
*xp = '/'; /* for now... (mkdir()) */
#else /* !VMS */
#ifdef MACOS
strcat(cdp, ":");
#else /* !MACOS */
strcat(cdp, "/");
#endif /* ?MACOS */
#endif /* ?VMS */
}
pp = name;
break;
case ':':
#ifdef UNIX /* colon is a valid character in Unix */
*pp++ = workch; /* filenames, so keep it; anywhere else, */
#else /* !UNIX */ /* change it to an underscore (should */
*pp++ = '_'; /* NOT have stored drive/node names!!) */
#endif /* ?UNIX */
/* pp = name; (OLD) discard DEC dev: or node:: name */
break;
case '.': /* DEC-20 generation number or */
#ifdef DOS_VMS /* MS-DOS or VMS separator */
last_dot = pp; /* point at last dot so far... */
*pp++ = '_'; /* convert dot to underscore */
#else /* !DOS_VMS */
*pp++ = workch;
#endif /* ?DOS_VMS */
break;
case ';': /* VMS generation or DEC-20 attrib */
#ifdef MACOS
if (V_flag || macflag)
#else /* !MACOS */
if (V_flag) /* if requested, save VMS ";##" */
#endif /* ?MACOS */ /* version info or Macintosh */
*pp++ = (char) workch; /* (?) info; otherwise discard */
else /* everything starting with */
done = TRUE; /* semicolon. (Worry about */
break; /* DEC-20 later.) */
case '\026': /* control-V quote for special chars */
quote = TRUE; /* set flag for next character */
break;
case ' ':
#if (defined(VMS) || defined(MTS))
*pp++ = '_'; /* change spaces to underscore */
#else /* !(VMS || MTS) */ /* under VMS and MTS, and under DOS */
#ifdef DOS_OS2 /* and OS/2 if -s not specified. */
if (!sflag)
*pp++ = '_';
else
#endif /* DOS_OS2 */
*pp++ = (char) workch; /* otherwise, leave as spaces */
#endif /* ?(VMS || MTS) */
break;
default:
#ifdef MACOS
if ((macflag && ((unsigned)workch > 0x1F)) || isprint(workch))
#else /* !MACOS */
#if (defined(DOS_OS2) || (defined(UNIX) && !defined(VMS))) /* allow non-US */
if (isprint(workch) || (128 <= workch && workch <= 254))
#else /* !(DOS_OS2 || UNIX) */
if (isprint(workch)) /* other printable, just keep */
#endif /* ?(DOS_OS2 || UNIX) */
#endif /* ?MACOS */
*pp++ = (char) workch;
} /* end switch */
} /* end for loop */
*pp = '\0'; /* done with name: terminate it */
#ifdef DOS_VMS /* and put a dot back in if VMS */
if (last_dot != NULL) /* or MS-DOS */
*last_dot = '.';
#endif /* DOS_VMS */
/*---------------------------------------------------------------------------
We COULD check for existing names right now, create a "unique" name, etc.
At present, we do this in extract_or_test_files() (immediately after we
return from here). If conversion went bad, the name'll either be nulled
out (in which case we'll return non-0), or following procedures won't be
able to create the extracted file and other error msgs will result.
---------------------------------------------------------------------------*/
if (filename[strlen(filename) - 1] == '/') {
/* A directory was extracted. It had a trailing /,
* don't report the error below. */
if (created) {
printf(" Creating: %s", filename);
#ifdef OS2
SetPathInfo(filename, lrec.last_mod_file_date,
lrec.last_mod_file_time, -1);
if (extra_field)
SetEAs(filename, extra_field);
#endif
printf("\n");
}
if (!jflag)
free(cdp);
return 2; /* but skip file */
}
if (*name == '\0') {
fprintf(stderr, "mapname: conversion of [%s] failed\n", filename);
if (!jflag)
free(cdp);
return 3;
}
#ifdef OS2
if (!longname && ((longname = !IsFileNameValid(name)) != 0)) {
/* in case of second call after user renamed the file, skip this */
last = strrchr(name, '/'); /* THIS time, save for file_io */
last = last ? last + 1 : name; /* only last component */
strcpy(longfilename, last);
fprintf(stderr, "renaming \"%s\"", name);
ChangeNameForFAT(last);
fprintf(stderr, " to \"%s\"\n", name);
}
#endif /* OS2 */
#ifdef VMS
/* convert filename to legal VMS one, substituting underscores for
* all invalid characters */
for (np = name; *np; ++np)
if (!(isdigit(*np) || isalpha(*np) || (*np == '$') ||
(*np == '-') || (*np == '_') || (*np == '.') || (*np == ';')))
*np = '_';
#endif /* VMS */
if (!jflag) {
#ifdef VMS
*xp++ = ']'; /* proper end-of-dir-name delimiter */
if (xp == cdp) { /* no path-name stuff, so... */
strcpy(filename, name); /* copy file name into global */
cdp -= 2; /* prepare to free malloc'd space */
} else { /* we've added path-name stuff... */
*xp = '\0'; /* so terminate and convert to */
dp = cdp; /* VMS subdir separators (skip */
while (*++dp) /* first char: better not be */
if (*dp == '/') /* "/"): change all slashes */
*dp = '.'; /* to dots */
cdp -= 2; /* include leading bracket and dot */
strcpy(filename, cdp); /* copy VMS-style path name into global */
strcat(filename, name); /* concatenate file name to global */
}
#else /* !VMS */
strcpy(filename, cdp); /* either "" or slash-terminated path */
strcat(filename, name); /* append file name to path name */
#endif /* ?VMS */
free(cdp);
} else
strcpy(filename, name); /* copy converted name into global */
#if PATH_MAX < (FILNAMSIZ - 1)
/* check the length of the file name and truncate if necessary */
if (PATH_MAX < strlen(filename)) {
fprintf(stderr, "caution: truncating filename\n");
filename[PATH_MAX] = '\0';
fprintf(stderr, "[ %s ]\n", filename);
return 1; /* 1: warning error */
}
#endif
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -