char *ret;
int pathLen = strlen(Path);
int read, write;
- int pos, slashNum=1, baseLen;
- Uint slashOffsets[MAX_PATH_SLASHES] = {1};
+ int pos, baseLen;
+ int slashNum = 0;
+ Uint slashOffsets[MAX_PATH_SLASHES];
char *cwd = CFGPTR(CFG_VFS_CWD);
int cwdLen;
if(strncmp(&ret[read], "..", pos-read) == 0)
{
// If there is no higher, silently ignore
- if(slashNum < 2) continue;
+ if(slashNum < 1) {
+ write = 1;
+ continue;
+ }
// Reverse write pointer
- write = slashOffsets[ --slashNum - 1 ];
+ write = slashOffsets[ --slashNum ];
continue;
}
}
Log("write = %i, read = %i", write, read);
memcpy( &ret[write], &ret[read], pos-read+1 );
}
- write += (pos-read)+1;
if(slashNum < MAX_PATH_SLASHES)
slashOffsets[ slashNum++ ] = write;
LEAVE('n');
return NULL;
}
+
+ // Increment write pointer
+ write += (pos-read)+1;
}
// `ret` should now be the absolute path