home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 August - Disc 3
/
chip_20018103_hu.iso
/
amiga
/
chiputil
/
gg
/
convertamigapath.lha
/
convertpath.c
Wrap
C/C++ Source or Header
|
2001-06-21
|
658b
|
40 lines
#include <stdlib.h>
char *__amigapath(const char *path)
{
static char *amipath=NULL;
char *temp=NULL;
int ucur=0,acur=0;
if (amipath)
free(amipath);
temp=(char *)(malloc(strlen(path)+1));
if (temp==NULL)
return(NULL);
for (;path[ucur]!='\0';acur++,ucur++) {
if (path[ucur]=='.') {
if ((path[ucur+1]=='.')&&(path[ucur+2]=='/')) {
acur--;
ucur++;
continue;
}
if (path[ucur+1]=='/') {
acur--;
ucur++;
continue;
}
}
temp[acur]=path[ucur];
}
temp[acur]='\0';
amipath=(char *)(malloc(strlen(temp)+1));
if (amipath)
strcpy(amipath,temp);
free(temp);
return(amipath);
}