1c6eff1c4311b33f525c979cb95d92a601e8f848
10 #include <sys/types.h>
14 #define DIR_SEPARATOR_CHAR '\\'
15 #define DIR_SEPARATOR_STRING "\\"
17 #define DIR_SEPARATOR_CHAR '/'
18 #define DIR_SEPARATOR_STRING "/"
21 char* convert_path(char* origpath
)
26 //newpath = strdup(origpath);
27 newpath
=malloc(strlen(origpath
)+1);
28 strcpy(newpath
,origpath
);
31 while (newpath
[i
] != 0)
34 if (newpath
[i
] == '\\')
40 if (newpath
[i
] == '/')
51 #define TRANSFER_SIZE (65536)
53 int mkdir_p(char* path
)
60 if (mkdir(path
, 0755) != 0)
62 perror("Failed to create directory");
68 perror("Failed to create directory");
75 perror("Failed to change directory");
81 int main(int argc
, char* argv
[])
89 fprintf(stderr
, "Too many arguments\n");
93 path1
= convert_path(argv
[1]);
95 if (isalpha(path1
[0]) && path1
[1] == ':' && path1
[2] == DIR_SEPARATOR_CHAR
)
97 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
98 sprintf(buf
, "%s\\", csec
);
100 csec
= strtok(NULL
, DIR_SEPARATOR_STRING
);
102 else if (path1
[0] == DIR_SEPARATOR_CHAR
)
104 chdir(DIR_SEPARATOR_STRING
);
105 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
109 csec
= strtok(path1
, DIR_SEPARATOR_STRING
);
115 csec
= strtok(NULL
, DIR_SEPARATOR_STRING
);