ReactOS  0.4.15-dev-489-g75a0787
rmkdir.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <sys/stat.h>
5 #include <unistd.h>
6 #include <ctype.h>
7 
8 #define DOS_PATH_CHAR '\\'
9 #define UNIX_PATH_CHAR '/'
10 
11 #if defined (__DJGPP__) || defined (__WIN32__)
12 #define DOS_PATHS
13 #define PATH_CHAR '\\'
14 #define PATH_CHAR_STR "\\"
15 #else
16 #define UNIX_PATHS
17 #define PATH_CHAR '/'
18 #define PATH_CHAR_STR "/"
19 #endif
20 
22 {
23  int i;
24 
25  i = 0;
26  while (Path[i] != 0)
27  {
28  if (Path[i] == DOS_PATH_CHAR || Path[i] == UNIX_PATH_CHAR)
29  {
30  Path[i] = PATH_CHAR;
31  }
32 
33  i++;
34  }
35 }
36 
38 {
39  char CurrentDirectory[1024];
40 
41  getcwd(CurrentDirectory, 1024);
42 
43  if (chdir(Directory) == 0)
44  {
46  return 0;
47  }
48 
49 #if defined (UNIX_PATHS) || defined (__DJGPP__)
50  if (mkdir(Directory, 0755) != 0)
51  {
52  perror("Failed to create directory");
53  return 1;
54  }
55 #else
56  if (mkdir(Directory) != 0)
57  {
58  perror("Failed to create directory");
59  return 1;
60  }
61 #endif
62 
63  if (chdir(Directory) != 0)
64  {
65  perror("Failed to change directory");
66  return 1;
67  }
68 
70 
71  return 0;
72 }
73 
74 int main(int argc, char* argv[])
75 {
76  if (argc != 2)
77  {
78  fprintf(stderr, "Wrong number of arguments\n");
79  exit(1);
80  }
81 
83 
84  return MakeDirectory(argv[1]);
85 }
#define UNIX_PATH_CHAR
Definition: rmkdir.c:9
static int argc
Definition: ServiceArgs.c:12
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
#define argv
Definition: mplay32.c:18
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define chdir
Definition: syshdrs.h:69
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define mkdir
Definition: acwin.h:101
void ConvertPathCharacters(char *Path)
Definition: rmkdir.c:21
#define PATH_CHAR
Definition: rmkdir.c:17
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
int MakeDirectory(char *Directory)
Definition: rmkdir.c:37
#define DOS_PATH_CHAR
Definition: rmkdir.c:8
PRTL_UNICODE_STRING_BUFFER Path
int main(int argc, char *argv[])
Definition: rmkdir.c:74
FILE * stderr
base for all directory entries
Definition: entries.h:138
void exit(int exitcode)
Definition: _exit.c:33