reformat and simplify before adding functionality

svn path=/branches/xmlbuildsystem/; revision=14076
This commit is contained in:
Royce Mitchell III 2005-03-14 21:59:25 +00:00
parent defea05242
commit effadc5c83

View file

@ -10,41 +10,39 @@
#include <sys/types.h>
#endif
#if defined(WIN32)
#define DIR_SEPARATOR_CHAR '\\'
#define DIR_SEPARATOR_STRING "\\"
#define DOS_PATHS
#define WIN_SEPARATOR_CHAR '\\'
#define WIN_SEPARATOR_STRING "\\"
#define NIX_SEPARATOR_CHAR '/'
#define NIX_SEPARATOR_STRING "/"
#ifdef WIN32
#define DIR_SEPARATOR_CHAR WIN_SEPARATOR_CHAR
#define DIR_SEPARATOR_STRING WIN_SEPARATOR_STRING
#define BAD_SEPARATOR_CHAR NIX_SEPARATOR_CHAR
#define MKDIR(s) mkdir(s)
#else
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STRING "/"
#define UNIX_PATHS
#define DIR_SEPARATOR_CHAR NIX_SEPARATOR_CHAR
#define DIR_SEPARATOR_STRING NIX_SEPARATOR_STRING
#define BAD_SEPARATOR_CHAR WIN_SEPARATOR_CHAR
#define MKDIR(s) mkdir(s,0755)
#endif
char* convert_path(char* origpath)
char*
convert_path(char* origpath)
{
char* newpath;
int i;
//newpath = strdup(origpath);
newpath=malloc(strlen(origpath)+1);
strcpy(newpath,origpath);
i = 0;
while (newpath[i] != 0)
{
#ifdef UNIX_PATHS
if (newpath[i] == '\\')
if (newpath[i] == BAD_SEPARATOR_CHAR)
{
newpath[i] = '/';
newpath[i] = DIR_SEPARATOR_CHAR;
}
#else
#ifdef DOS_PATHS
if (newpath[i] == '/')
{
newpath[i] = '\\';
}
#endif
#endif
i++;
}
return(newpath);
@ -58,20 +56,11 @@ int mkdir_p(char* path)
{
return(0);
}
#ifdef UNIX_PATHS
if (mkdir(path, 0755) != 0)
if (MKDIR(path) != 0)
{
perror("Failed to create directory");
exit(1);
}
#else
if (mkdir(path) != 0)
{
perror("Failed to create directory");
exit(1);
}
#endif
if (chdir(path) != 0)
{
perror("Failed to change directory");