ReactOS  0.4.15-dev-321-g2d9b385
rmkdir.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
Include dependency graph for rmkdir.c:

Go to the source code of this file.

Macros

#define DOS_PATH_CHAR   '\\'
 
#define UNIX_PATH_CHAR   '/'
 
#define UNIX_PATHS
 
#define PATH_CHAR   '/'
 
#define PATH_CHAR_STR   "/"
 

Functions

void ConvertPathCharacters (char *Path)
 
int MakeDirectory (char *Directory)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ DOS_PATH_CHAR

#define DOS_PATH_CHAR   '\\'

Definition at line 8 of file rmkdir.c.

◆ PATH_CHAR

#define PATH_CHAR   '/'

Definition at line 17 of file rmkdir.c.

◆ PATH_CHAR_STR

#define PATH_CHAR_STR   "/"

Definition at line 18 of file rmkdir.c.

◆ UNIX_PATH_CHAR

#define UNIX_PATH_CHAR   '/'

Definition at line 9 of file rmkdir.c.

◆ UNIX_PATHS

#define UNIX_PATHS

Definition at line 16 of file rmkdir.c.

Function Documentation

◆ ConvertPathCharacters()

void ConvertPathCharacters ( char Path)

Definition at line 21 of file rmkdir.c.

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 }
#define UNIX_PATH_CHAR
Definition: rmkdir.c:9
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 PATH_CHAR
Definition: rmkdir.c:17
#define DOS_PATH_CHAR
Definition: rmkdir.c:8
PRTL_UNICODE_STRING_BUFFER Path

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 74 of file rmkdir.c.

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 }
static int argc
Definition: ServiceArgs.c:12
#define argv
Definition: mplay32.c:18
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void ConvertPathCharacters(char *Path)
Definition: rmkdir.c:21
int MakeDirectory(char *Directory)
Definition: rmkdir.c:37
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33

◆ MakeDirectory()

int MakeDirectory ( char Directory)

Definition at line 37 of file rmkdir.c.

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 }
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
#define chdir
Definition: syshdrs.h:69
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define mkdir
Definition: acwin.h:101
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
base for all directory entries
Definition: entries.h:138

Referenced by main().