2 * AcessOS Shell Version 2
\r
4 * See file COPYING for
\r
11 * \fn int GeneratePath(char *file, char *base, char *Dest)
\r
12 * \brief Generates a path given a base and a filename
\r
15 int GeneratePath(char *file, char *base, char *Dest)
\r
17 char *pathComps[64];
\r
25 pathComps[iPos++] = tmpStr = base+1;
\r
28 if(*tmpStr++ == '/')
\r
30 pathComps[iPos] = tmpStr;
\r
36 //Print(" GeneratePath: Base Done\n");
\r
38 // Parse Argument Path
\r
39 pathComps[iPos++] = tmpStr = file;
\r
42 if(*tmpStr++ == '/')
\r
44 pathComps[iPos] = tmpStr;
\r
48 pathComps[iPos] = NULL;
\r
50 //Print(" GeneratePath: Path Done\n");
\r
54 while(pathComps[iPos])
\r
56 tmpStr = pathComps[iPos];
\r
57 // Always Increment iPos
\r
60 if(tmpStr[0] == '.' && tmpStr[1] == '.' && (tmpStr[2] == '/' || tmpStr[2] == '\0') )
\r
67 if(tmpStr[0] == '.' && (tmpStr[1] == '/' || tmpStr[1] == '\0') )
\r
72 if(tmpStr[0] == '/' || tmpStr[0] == '\0')
\r
78 pathComps[iPos2] = tmpStr;
\r
81 pathComps[iPos2] = NULL;
\r
84 iPos2 = 1; iPos = 0;
\r
86 while(pathComps[iPos])
\r
88 tmpStr = pathComps[iPos];
\r
89 while(*tmpStr && *tmpStr != '/')
\r
91 Dest[iPos2++] = *tmpStr;
\r
94 Dest[iPos2++] = '/';
\r
102 return iPos2; //Length
\r