home *** CD-ROM | disk | FTP | other *** search
- Save Format v2.0(1)
- @begin ClassFile "DDir_Walker"
- Exported 0;
- Abstract 0;
- Interface 0;
- PackageName "";
- Language "Java";
-
- @begin UserFunction "DDir_Walker()"
- Compiler 1;
- GencodeSrcLine 12;
- FunctionName "DDir_Walker::DDir_Walker()";
- @end;
-
- @begin UserFunction "main(String args[])"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 16;
- FunctionName "DDir_Walker::main(String args[])";
- @end;
-
- @begin UserFunction "CreateMainForm()"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 23;
- FunctionName "DDir_Walker::CreateMainForm()";
- @end;
-
- @begin UserFunction "StartApp(String args[])"
- Compiler 1;
- GencodeSrcLine 26;
- FunctionName "DDir_Walker::StartApp(String args[])";
- @end;
-
- @begin UserFunction "RunApp(String args[])"
- Compiler 1;
- GencodeSrcLine 39;
- FunctionName "DDir_Walker::RunApp(String args[])";
- @end;
-
- @begin UserFunction "EndApp(String args[])"
- Compiler 1;
- GencodeSrcLine 145;
- FunctionName "DDir_Walker::EndApp(String args[])";
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- // add your custom import statements here
- import java.io.*;
- import java.util.*;
-
- @end-code;
- GencodeSrcLine 6;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- // add your data members here
- DynamoConnection dynamo;
- Document document;
- DBConnection connection;
- Session session;
-
- @end-code;
- GencodeSrcLine 148;
- @end;
-
- @begin-code BaseClassList
-
- extends Object
-
- @end-code;
-
- @begin-code GeneratedClassContents
-
-
- @end-code;
-
- @begin-code Code "DDir_Walker::DDir_Walker()"
-
- public @CLASSNAME@()
- {
- super();
- }
-
- @end-code;
-
- @begin-code Code "DDir_Walker::main(String args[])"
-
- public static void main(String args[])
- {
- @@CLASSNAME@ app = new @CLASSNAME@();
- app.StartApp(args);
- app.RunApp(args);
- app.EndApp(args);
- }
-
- @end-code;
-
- @begin-code Code "DDir_Walker::CreateMainForm()"
-
- public void CreateMainForm()
- {
- }
-
- @end-code;
-
- @begin-code Code "DDir_Walker::StartApp(String args[])"
-
- public void StartApp(String args[])
- {
- dynamo = new DynamoConnection( args );
- if(! dynamo.getConnected() ) {
- System.err.println( "Connection to NetImpact Dynamo failed" );
- System.exit(2);
- }
- // Define wrapper classes
- document = dynamo.getDocument();
- connection = dynamo.getDBConnection();
- session = dynamo.getSession();
-
- }
-
- @end-code;
-
- @begin-code Code "DDir_Walker::RunApp(String args[])"
-
- public void RunApp(String args[])
- {
- //CreateMainForm();
- try {
- document.writeln( "<CENTER><H1>Java Dynamo Directory Walker Sample" );
- document.writeln( "<P>\n<BR>\n<HR>\n<BR>" );
-
-
- String directory = args[1];
- Vector dirList = new Vector( 100 );
-
- // If no directory specified, print an error message
- if( directory.equals( null ) || directory.equals( new String( "" ) ) ) {
- document.writeln( "<H2>No directory specified" );
- return;
- }
-
- // Create and check if actually is a directory
- File currentDir = new File( directory );
- if( !currentDir.isDirectory() ) {
- document.writeln( "<H2>Directory " + directory + " doesn't exist." );
- return;
- }
-
- // Add directory to the list
- dirList.addElement( currentDir );
-
- for( ; dirList.size() > 0 ; ) {
- // Get and remove the first dir off the list
- File cwd = ( File ) dirList.firstElement();
- dirList.removeElementAt( 0 );
-
- String[] fileList = cwd.list();
-
- // Print out the current directory and the table headers
- document.writeln( "<P>" );
- document.write( "<CENTER><H2>Directory: " );
- document.write( cwd.toString() );
- document.writeln( "</H2></CENTER>" );
-
- document.writeln( "<CENTER><TABLE BORDER=4 BGCOLOR=WHITE>" );
- document.writeln( "<TR>" );
- document.writeln( "<TH>Name</TH>" );
- document.writeln( "<TH>Type</TH>" );
- document.writeln( "<TH>Read</TH>" );
- document.writeln( "<TH>Write</TH>" );
- document.writeln( "<TH>Length</TH>" );
- document.writeln( "<TH>Last Modified</TH>" );
- document.writeln( "</TR>" );
-
- for( int row=0; row<fileList.length; row++ ) {
- String fileName = fileList[row];
- File aFile = new File( cwd, fileName );
-
- document.writeln( "<TR>" );
-
- document.write( "<TD>" );
- document.write( fileName );
- document.writeln( "</TD>" );
-
- // Check if file is a file or a directory
- // If it's a directory, add to the list
- if( aFile.isDirectory() ) {
- document.writeln( "<TD>Directory</TD>" );
- dirList.addElement( aFile );
- } else if( aFile.isFile() ) {
- document.writeln( "<TD>File</TD>" );
- } else {
- document.writeln( "<TD>Unknown</TD>" );
- }
-
- // Check if file is readable
- if( aFile.canRead() ) {
- document.writeln( "<TD>Yes</TD>" );
- } else {
- document.writeln( "<TD>No</TD>" );
- }
-
- // Check if file is writable
- if( aFile.canWrite() ) {
- document.writeln( "<TD>Yes</TD>" );
- } else {
- document.writeln( "<TD>No</TD>" );
- }
-
- // Get length of file
- document.write( "<TD>" );
- document.write( Long.toString( aFile.length() ) );
- document.writeln( "</TD>" );
-
- // Get the 'last modified' date and time of file
- document.write( "<TD>" );
- document.write( (new Date( aFile.lastModified() )).toLocaleString() );
- document.writeln( "</TD>" );
-
- document.writeln( "</TR>" );
- }
-
- document.writeln( "</TABLE></CENTER>" );
- }
- document.writeln( "<P>\n<BR>\n<HR>\n<BR>" );
-
- } catch( DynamoException e ) {
- }
-
- }
-
- @end-code;
-
- @begin-code Code "DDir_Walker::EndApp(String args[])"
-
- public void EndApp(String args[])
- {
- }
-
- @end-code;
- @end;
-