home *** CD-ROM | disk | FTP | other *** search
- /*
- Stuff 2.0.
-
- Checksum: 3171002767 (verify with "brik")
-
- (C) Copyright 1988 Rahul Dhesi. Permission is granted to copy and
- distribute this file in modified or unmodified form, whether for
- noncommercial or commercial use, provided (a) this copyright notice
- is preserved, (b) no attempt is made to restrict redistribution of
- this file, and (c) this file is not distributed as part of any
- collection whose redistribution is restricted by a compilation
- copyright.
- */
-
- /*
- Deals with a single argument
- */
-
- #include <stdio.h>
-
- #include <dir.h>
- #include <dos.h>
- #include <string.h>
- #include <stddef.h>
- #include <errno.h>
- #include "stuff.h"
-
- #include <conio.h> /* for kbhit() only */
-
- struct file_info file_info;
-
- void doarg (char *pathname)
- {
- struct ffblk ffblk;
- int done;
- name_pt this_path;
- name_pt newname;
- char *p;
-
- kbhit();
-
- strcpy (this_path, pathname);
- assert (strlen(this_path) != 0);
-
- forceslash (this_path); /* redundant but just being sure */
-
- if (STRCMP(this_path,==,".") || STRCMP(this_path,==,".."))
- strcat(this_path,"/*.*");
- if (findlast(this_path,":\\/") == lastptr(this_path)) /* trailing : / \ */
- strcat(this_path,"*.*");
-
- /* if not a pathname or disk name, add leading ./ to it */
- if (findlast(this_path,":/") == NULL) {
- strcpy (newname, "./");
- strcat (newname, this_path);
- strcpy (this_path, newname);
- }
-
- done = findfirst (this_path, &ffblk, FA_DIREC);
- if (done) {
- fprintf (stderr, "%s: not found\n", this_path);
- return;
- }
- file_info.utime = mstonix (ffblk.ff_fdate, ffblk.ff_ftime);
- file_info.size = ffblk.ff_fsize;
- file_info.attrib = ffblk.ff_attrib;
-
- /* now we remove any trailing filename component from this_path */
- p = findlast (this_path, "/\\:");
- if (p != NULL)
- *(p+1) = '\0';
-
- while (!done) {
- if (ffblk.ff_attrib & FA_DIREC) {
- if (ffblk.ff_name[0] != '.') {
- strcpy (newname, this_path);
- strcat (newname, ffblk.ff_name);
- strcat (newname, "/*.*");
- doarg (newname);
- }
- } else {
- strcpy (newname, this_path);
- strcat (newname, ffblk.ff_name);
- dopath (newname, &file_info);
- }
- done = findnext (&ffblk);
- file_info.utime = mstonix (ffblk.ff_fdate, ffblk.ff_ftime);
- file_info.size = ffblk.ff_fsize;
- file_info.attrib = ffblk.ff_attrib;
- }
- }
-