2 * AcessOS Shell Version 2
\r
4 * See file COPYING for
\r
10 * \fn int GeneratePath(char *file, char *base, char *Dest)
\r
11 * \brief Generates a path given a base and a filename
\r
14 int GeneratePath(char *file, char *base, char *Dest)
\r
16 char *pathComps[64];
\r
24 pathComps[iPos++] = tmpStr = base+1;
\r
27 if(*tmpStr++ == '/')
\r
29 pathComps[iPos] = tmpStr;
\r
35 //Print(" GeneratePath: Base Done\n");
\r
37 // Parse Argument Path
\r
38 pathComps[iPos++] = tmpStr = file;
\r
41 if(*tmpStr++ == '/')
\r
43 pathComps[iPos] = tmpStr;
\r
47 pathComps[iPos] = NULL;
\r
49 //Print(" GeneratePath: Path Done\n");
\r
53 while(pathComps[iPos])
\r
55 tmpStr = pathComps[iPos];
\r
56 // Always Increment iPos
\r
59 if(tmpStr[0] == '.' && tmpStr[1] == '.' && (tmpStr[2] == '/' || tmpStr[2] == '\0') )
\r
66 if(tmpStr[0] == '.' && (tmpStr[1] == '/' || tmpStr[1] == '\0') )
\r
71 if(tmpStr[0] == '/' || tmpStr[0] == '\0')
\r
77 pathComps[iPos2] = tmpStr;
\r
80 pathComps[iPos2] = NULL;
\r
83 iPos2 = 1; iPos = 0;
\r
85 while(pathComps[iPos])
\r
87 tmpStr = pathComps[iPos];
\r
88 while(*tmpStr && *tmpStr != '/')
\r
90 Dest[iPos2++] = *tmpStr;
\r
93 Dest[iPos2++] = '/';
\r
101 return iPos2; //Length
\r