- // FIXME: This is probably still buggy
- // FEATURE: Remove some of the "should never happen checks"
- /*protected static String cleanupPath(String p) throws ErrnoException {
- if(p.length() == 0) throw new ErrnoException(ENOENT);
- if(needsCleanup(p)) {
- char[] in = p.toCharArray();
- char[] out;
- int outp ;
- if(in[0] == '/') {
- out = new char[in.length];
- outp = 0;
- } else {
- out = new char[cwd.length() + in.length + 1];
- outp = cwd.length();
- for(int i=0;i<outp;i++) out[i] = cwd.charAt(i);
- if(outp == 0 || out[0] != '/') throw new Error("should never happen");
- }
- int inLength = in.length;
- int inp = 0;
- while(inp<inLength) {
- if(inp == 0 || in[inp] == '/') {
- while(inp < inLength && in[inp] == '/') inp++;
- if(inp == inLength) break;
- if(in[inp] == '.') {
- if(inp+1 == inLength) break;
- if(in[inp+1] == '.' && (inp+2 == inLength || in[inp+2] == '/')) {
- inp+=2;
- if(outp == 0) continue;
- do { outp--; } while(outp > 0 && out[outp] != '/');
- } else if(in[inp+1] == '/') {
- inp++;
- } else {
- out[outp++] = '/';
- }
- } else {
- out[outp++] = '/';
- out[outp++] = in[inp++];
- }
- } else {
- out[outp++] = in[inp++];
- }
- }
- if(outp == 0) out[outp++] = '/';
- return new String(out,0,outp);
- } else {
- if(p.startsWith("/")) return p;
- StringBuffer sb = new StringBuffer(cwd);
- if(!cwd.equals("/")) sb.append('/');
- return sb.append(p).toString();
- }
- }*/
-