Fixed prototype for MmSetAddressRangeModified().
[reactos.git] / tools / rrmdir.c
1 /*  $Id$  
2  * COPYRIGHT:             See COPYING in the top level directory
3  * PROGRAMMER:            Rex Jolliff (rex@lvcablemodem.com)
4  *                        Casper S. Hornstrup (chorns@users.sourceforge.net)
5  * PURPOSE:               Platform independant remove directory command
6  */
7
8 #include <dirent.h>
9 #include <errno.h>
10 #include <limits.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14
15 void 
16 convertPath (char * pathToConvert)
17 {
18   while (*pathToConvert != 0)
19   {
20     if (*pathToConvert == '\\')
21     {
22       *pathToConvert = '/';
23     }
24     pathToConvert++;
25   }
26 }
27
28 void
29 getDirectory (const char *filename, char * directorySpec)
30 {
31   int  lengthOfDirectory;
32
33   if (strrchr (filename, '/') != 0)
34   {
35     lengthOfDirectory = strrchr (filename, '/') - filename;
36     strncpy (directorySpec, filename, lengthOfDirectory);
37     directorySpec [lengthOfDirectory] = '\0';
38   }
39   else
40   {
41     strcpy (directorySpec, ".");
42   }
43 }
44
45 void
46 getFilename (const char *filename, char * fileSpec)
47 {
48   if (strrchr (filename, '/') != 0)
49   {
50     strcpy (fileSpec, strrchr (filename, '/') + 1);
51   }
52   else
53   {
54     strcpy (fileSpec, filename);
55   }
56 }
57
58 int 
59 main (int argc, char* argv[])
60 {
61   int  justPrint = 0;
62   int  idx;
63   int  returnCode;
64
65   for (idx = 1; idx < argc; idx++)
66   {
67     convertPath (argv [idx]);
68
69     if (justPrint)
70     {
71       printf ("remove %s\n", argv [idx]);
72     }
73     else
74     {
75       returnCode = rmdir (argv [idx]);
76       if (returnCode != 0 && errno != ENOENT)
77       {
78       /* Continue even if there is errors */
79 #if 0
80         printf ("Rmdir of %s failed.  Rmdir returned %d.\n", 
81                 argv [idx],
82                 returnCode);
83         return  returnCode;
84 #endif
85       }
86     }
87   }
88
89   return  0;
90 }
91
92