<html> <head> <style type="text/css"> <!-- H3, h3 { font-family: arial, helvetica, sans-serif; font-size: 14px; } td, TD, th, TH, body, BODY { font-family: courier; font-size: 10px; } A { text-decoration: none; } --> </style> <title> Mid-Afternoon Commander </title> </head>
$use("codex.io") $use("codex.util") $use("codex.http")
${ int S_IRWXU =7<<6 ; /* RWX mask for owner */ int S_IRUSR =4<<6 ; /* R for owner */ int S_IWUSR =2<<6 ; /* W for owner */ int S_IXUSR =1<<6 ; /* X for owner */
int S_IRWXG =7<<3 ; /* RWX mask for group */ int S_IRGRP =4<<3 ; /* R for group */ int S_IWGRP =2<<3 ; /* W for group */ int S_IXGRP =1<<3 ; /* X for group */
int S_IRWXO =7 ; /* RWX mask for other */ int S_IROTH =4 ; /* R for other */ int S_IWOTH =2 ; /* W for other */ int S_IXOTH =1 ; /* X for other */ PosixFileSystem fs = localFileSystem();
String cwd = getValue("cwd","."); cwd= fs.canonicalPathForPath(cwd); }$
<body>
${ switch(getValue("_op","")){ case "create directory": fs.createDirectory(cwd+"/"+getValue("_dir")); fs.setMode(cwd+"/"+getValue("_dir"),S_IRWXO|S_IRWXG|S_IRWXU); print "<font color=\"#00AA00\">Directory "+getValue("_dir")+" created</font><p>"; case "delete file": fs.removeFile(cwd+"/"+getValue("_file")); print "<font color=\"#00AA00\">File "+getValue("_file")+" deleted</font><p>"; case "delete directory": fs.removeDirectory(cwd+"/"+getValue("_dir")); print "<font color=\"#00AA00\">Directory "+getValue("_dir")+" deleted</font><p>"; case "create symbolic link": fs.createSymbolicLink(cwd+'/'+getValue("_dest"),cwd+'/'+getValue("_src")); print "<font color=\"#00AA00\">Symbolic Link "+getValue("_src")+" created</font><p>"; } }$
<table><tr><td valign=top> <table border=0 bgcolor="#666666" align="center" cellpadding=1 cellspacing=0> <tr><td> <table border=0 bgcolor="#FFFFFF" width="100%" cellpadding=3 cellspacing=1> <tr bgcolor="#EEEEEE"> <th> Create Directory</th> </tr> <tr><td> <form method=post> <input type="hidden" name="_op" value="create directory"> $(formHidden("cwd",cwd)) Create Directory $(formTextfield("_dir","",20,100))<br> <input type=submit value="create directory"> </form> </td></tr> </table></td></tr></table> <p>
<table border=0 bgcolor="#666666" align="center" cellpadding=1 cellspacing=0> <tr><td> <table border=0 bgcolor="#FFFFFF" width="100%" cellpadding=3 cellspacing=1> <tr bgcolor="#EEEEEE"> <th> Create Symbolic Link</th> </tr> <tr><td> <form method=post> <input type="hidden" name="_op" value="create symbolic link"> $(formHidden("cwd",cwd)) Link Name $(formTextfield("_src","",20,100))<br> Link Destination $(formTextfield("_dest","",20,100))<br> <input type=submit value="create symbolic link"> </form> </td></tr> </table></td></tr></table> <p> </td><td valign=top> <table border=0 bgcolor="#666666" align="center" cellpadding=1 cellspacing=0> <tr ><th height=20 align="center"> <font color="#EEEEEE"><b>$(cwd)</b></font> </th></tr><tr><td> <table border=0 bgcolor="#FFFFFF" width="100%" cellpadding=3 cellspacing=0> <tr bgcolor="#EEEEEE"><th height=20> </th><th height=20>file</th><th>size</th><th>perms</th><th>uid</th><th>gid</th> <th>atime</th><th>mtime</th><th>ctime</th></tr> ${ Enumeration e = fs.getEntries(cwd); while(e.hasNext()){ String file=<String>e.next(); String path=cwd+"/"+file; boolean isDirectory = false; int mode = fs.getMode(path);
print "<tr bgcolor=\"#FFFFFF\">";
if(fs.isDirectory(path)) isDirectory=true; else if(fs.isSymbolicLink(path)){ String lpath=fs.pathForSymbolicLink(path); if(!lpath.startsWith("/")) lpath = cwd + '/' + lpath; if(fs.isDirectory(lpath)) isDirectory=true; } print "<form method=\"post\">"; print "<td>"; print formHidden("cwd",cwd); if(!fs.isDirectory(path)){ print "<input type=\"hidden\" name=\"_op\" value=\"delete file\">"; print "<input type=\"hidden\" name=\"_file\" value=\""+urlEncode(file)+"\">"; } else { print "<input type=\"hidden\" name=\"_op\" value=\"delete directory\">"; print "<input type=\"hidden\" name=\"_dir\" value=\""+urlEncode(file)+"\">"; } print "<input type=\"image\" src=\"d_button.gif\" border=\"0\">"; print "</td></form><td>"; if(isDirectory) print "<a href=\"posix_file_io.moto?cwd="+urlEncode(path)+"\">"; if(fs.isSymbolicLink(path)) print "<font color=\"#FF00FF\">"; else if(fs.isDirectory(path)) print "<font color=\"#0000FF\">"; else print "<font>"; print "<b>"+file+"</b>"; if(fs.isSymbolicLink(path)) print " -> "+fs.pathForSymbolicLink(path); print "</font>"; if(isDirectory) print "</a>"; print "</td><td>"; print fs.getSize(path); print "</td><td>"; if(fs.isDirectory(path)) print 'd'; else if(fs.isSymbolicLink(path)) print 'l'; else print '-'; if((mode&S_IRUSR) > 0) print 'r'; else print '-'; if((mode&S_IWUSR) > 0) print 'w'; else print '-'; if((mode&S_IXUSR) > 0) print 'x'; else print '-'; if((mode&S_IRGRP) > 0) print 'r'; else print '-'; if((mode&S_IWGRP) > 0) print 'w'; else print '-'; if((mode&S_IXGRP) > 0) print 'x'; else print '-'; if((mode&S_IROTH) > 0) print 'r'; else print '-'; if((mode&S_IWOTH) > 0) print 'w'; else print '-'; if((mode&S_IXOTH) > 0) print 'x'; else print '-'; print "</td><td>"; print fs.getOwner(path); print "</td><td>"; print fs.getGroupOwner(path); print "</td><td>"; print fs.getLastAccessTime(path).toString("%m-%d-%Y"); print "</td><td>"; print fs.getLastModificationTime(path).toString("%m-%d-%Y"); print "</td><td>"; print fs.getLastChangeTime(path).toString("%m-%d-%Y"); print "</td></tr>"; print "\n"; } print "</table>"; }$ </table></td></tr></table> </td></tr></table> </body>
| |
Copyright © 2000 - 2003 David Hakim