10 #include <sys/types.h>
14 #define DIR_SEPARATOR_CHAR '\\'
15 #define DIR_SEPARATOR_STRING "\\"
18 #define DIR_SEPARATOR_CHAR '/'
19 #define DIR_SEPARATOR_STRING "/"
23 char* convert_path(char* origpath
)
28 //newpath = strdup(origpath);
29 newpath
=malloc(strlen(origpath
)+1);
30 strcpy(newpath
,origpath
);
33 while (newpath
[i
] != 0)
36 if (newpath
[i
] == '\\')
42 if (newpath
[i
] == '/')
53 #define TRANSFER_SIZE (65536)
55 int mkdir_p(char* path
)
62 if (mkdir(path
, 0755) != 0)
64 perror("Failed to create directory");
70 perror("Failed to create directory");
77 perror("Failed to change directory");
83 int main(int argc
, char* argv
[])
91 fprintf(stderr
, "Too many arguments\n");
95 path1
= convert_path(argv
[1]);
97 if (isalpha(path1
[0]) && path1
[1] == ':' && path1
[2] == DIR_SEPARATOR_CHAR
)
99 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
100 sprintf(buf
, "%s\\", csec
);
102 csec
= strtok(NULL
, DIR_SEPARATOR_STRING
);
104 else if (path1
[0] == DIR_SEPARATOR_CHAR
)
106 chdir(DIR_SEPARATOR_STRING
);
107 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
111 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
117 csec
= strtok(NULL
, DIR_SEPARATOR_STRING
);