- bool AbsolutePath(const char *relatif,char *actualpath)
- {
- unsigned int pos= 0;
-
- if (strstr(relatif,":\\")) {
- strcpy(actualpath,relatif);
- return true;
- }
-
- char *t = strrchr(actualpath,'\\');
- if (*t == '\\' && *(t+1) != '\0') *t = '\0';
-
-
- while (relatif[pos]) {
- if (relatif[pos] == '.' && relatif[pos+1] == '\\') {
- pos += 2;
- } else if (relatif[pos] == '.' && relatif[pos+1] == '.' && relatif[pos+2] == '\\' ) {
- pos += 3;
- char *l = strrchr(actualpath,'\\');
- if (*(l-1) == '\\') return false;
- *l = '\0';
- } else if (relatif[pos] == '\\') {
- pos++;
- } else {
- char *end = strchr(actualpath,'\0');
-
- while (relatif[pos] != '\\' && relatif[pos] != '\0') {
- *end = relatif[pos];
- pos++;
- *end++;
- }
- if (relatif[pos] == '\\' ) { *end = '\\'; *end++; }
- *end = '\0';
- }
- }
-
- return true;
- }
bool AbsolutePath(const char *relatif,char *actualpath)
{
unsigned int pos= 0;
if (strstr(relatif,":\\")) {
strcpy(actualpath,relatif);
return true;
}
char *t = strrchr(actualpath,'\\');
if (*t == '\\' && *(t+1) != '\0') *t = '\0';
while (relatif[pos]) {
if (relatif[pos] == '.' && relatif[pos+1] == '\\') {
pos += 2;
} else if (relatif[pos] == '.' && relatif[pos+1] == '.' && relatif[pos+2] == '\\' ) {
pos += 3;
char *l = strrchr(actualpath,'\\');
if (*(l-1) == '\\') return false;
*l = '\0';
} else if (relatif[pos] == '\\') {
pos++;
} else {
char *end = strchr(actualpath,'\0');
while (relatif[pos] != '\\' && relatif[pos] != '\0') {
*end = relatif[pos];
pos++;
*end++;
}
if (relatif[pos] == '\\' ) { *end = '\\'; *end++; }
*end = '\0';
}
}
return true;
}