|
|
1.1 root 1: /*
2: * Program to demonstrate DOSFINDFIRST and DOSMOVE.
3: *
4: * Compile as: cl -AL -G2 -Lp move.c
5: */
6:
7: #include <doscalls.h>
8: #include <stdio.h>
9: #include <string.h>
10:
11: #define BYTE unsigned char
12: #define WORD unsigned int
13: #define DWORD unsigned long
14:
15: main (argc, argv)
16: int argc ;
17: char *argv [] ;
18: {
19: struct FileFindBuf findbuf ;
20: WORD handle = 0xFFFF ;
21: WORD count = 1 ;
22: char oldpath [81], newpath [81], oldspec [81], newspec [81] ;
23: WORD code ;
24: char *ptr ;
25:
26: if (argc < 3) {
27: printf ("Syntax: MOVE filespec directory") ;
28: exit (1) ;
29: }
30:
31: strcpy (oldpath, strlwr (argv [1])) ;
32:
33: if (NULL != (ptr = strrchr (oldpath, '\\')) ||
34: NULL != (ptr = strrchr (oldpath, ':')))
35: *(ptr + 1) = '\0' ;
36: else
37: *oldpath = '\0' ;
38:
39: strcpy (newpath, strlwr (argv [2])) ;
40:
41: if (newpath [strlen (newpath) - 1] != '\\')
42: strcat (newpath, "\\") ;
43:
44: DOSFINDFIRST (argv [1], &handle, 7, &findbuf,
45: sizeof (findbuf), &count, 0L) ;
46:
47: while(count) {
48: strcpy (oldspec, oldpath) ;
49: strcat (oldspec, findbuf.file_name) ;
50:
51: strcpy (newspec, newpath) ;
52: strcat (newspec, findbuf.file_name) ;
53:
54: code = DOSMOVE (oldspec, newspec, 0L) ;
55:
56: printf ("%s --> %s %s\n", oldspec, newspec,
57: code ? "FAILED" : "") ;
58:
59: DOSFINDNEXT (handle, &findbuf, sizeof (findbuf), &count) ;
60: }
61:
62: DOSFINDCLOSE (handle) ;
63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.