german translation update
[reactos.git] / reactos / boot / freeldr / 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 #include <unistd.h>
15
16 void
17 convertPath (char * pathToConvert)
18 {
19 while (*pathToConvert != 0)
20 {
21 if (*pathToConvert == '\\')
22 {
23 *pathToConvert = '/';
24 }
25 pathToConvert++;
26 }
27 }
28
29 void
30 getDirectory (const char *filename, char * directorySpec)
31 {
32 int lengthOfDirectory;
33
34 if (strrchr (filename, '/') != 0)
35 {
36 lengthOfDirectory = strrchr (filename, '/') - filename;
37 strncpy (directorySpec, filename, lengthOfDirectory);
38 directorySpec [lengthOfDirectory] = '\0';
39 }
40 else
41 {
42 strcpy (directorySpec, ".");
43 }
44 }
45
46 void
47 getFilename (const char *filename, char * fileSpec)
48 {
49 if (strrchr (filename, '/') != 0)
50 {
51 strcpy (fileSpec, strrchr (filename, '/') + 1);
52 }
53 else
54 {
55 strcpy (fileSpec, filename);
56 }
57 }
58
59 int
60 main (int argc, char* argv[])
61 {
62 int justPrint = 0;
63 int idx;
64 int returnCode;
65
66 for (idx = 1; idx < argc; idx++)
67 {
68 convertPath (argv [idx]);
69
70 if (justPrint)
71 {
72 printf ("remove %s\n", argv [idx]);
73 }
74 else
75 {
76 returnCode = rmdir (argv [idx]);
77 if (returnCode != 0 && errno != ENOENT)
78 {
79 /* Continue even if there is errors */
80 #if 0
81 printf ("Rmdir of %s failed. Rmdir returned %d.\n",
82 argv [idx],
83 returnCode);
84 return returnCode;
85 #endif
86 }
87 }
88 }
89
90 return 0;
91 }
92
93