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