1 import java.util.*; 2 import java.text.*; 3 import java.net.*; 4 import jcifs.smb.*; 5 6 public class FileInfo { 7 8 static final String TYPES[] = { 9 "TYPE_COMM", 10 "TYPE_FILESYSTEM", 11 "TYPE_NAMED_PIPE", 12 "TYPE_PRINTER", 13 "TYPE_SERVER", 14 "TYPE_SHARE", 15 "TYPE_WORKGROUP" 16 }; 17 18 public static void main( String argv[] ) throws Exception { 19 int i, start, end;; 20 SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yy hh:mm:ss a" ); 21 GregorianCalendar cal = new GregorianCalendar(); 22 SmbFile f; 23 24 if( argv.length < 2 ) { 25 throw new IllegalArgumentException ( "usage: FileInfo <url> <opindex>" ); 26 } 27 28 if( argv.length == 3 ) { 29 SmbFile tmp = new SmbFile( argv[0] ); 30 f = new SmbFile( tmp.toString(), argv[1] ); 31 start = Integer.parseInt( argv[2] ); 32 } else { 33 f = new SmbFile( argv[0] ); 34 start = Integer.parseInt( argv[1] ); 35 } 36 37 sdf.setCalendar( cal ); 38 39 i = end = start; 40 do { 41 switch( i ) { 42 case 0: 43 System.out.println( " toString: " + f.toString() ); 44 break; 45 case 1: 46 System.out.println( " toURL: " + f.toURL() ); 47 break; 48 case 2: 49 System.out.println( " getName: " + f.getName() ); 50 break; 51 case 3: 52 System.out.println( " length: " + f.length() ); 53 break; 54 case 4: 55 System.out.println( " getLastModified: " + sdf.format( new Date( f.getLastModified() ))); 56 break; 57 case 5: 58 System.out.println( " isHidden: " + f.isHidden() ); 59 break; 60 case 6: 61 System.out.println( " isFile: " + f.isFile() ); 62 break; 63 case 7: 64 System.out.println( " isDirectory: " + f.isDirectory() ); 65 break; 66 case 8: 67 System.out.println( " hashCode: " + f.hashCode() ); 68 break; 69 case 9: 70 System.out.println( " getUncPath: " + f.getUncPath() ); 71 break; 72 case 10: 73 System.out.println( " getType: " + TYPES[f.getType()] ); 74 break; 75 case 11: 76 System.out.println( " getShare: " + f.getShare() ); 77 break; 78 case 12: 79 System.out.println( " getServer: " + f.getServer() ); 80 break; 81 case 13: 82 System.out.println( " getPath: " + f.getPath() ); 83 break; 84 case 14: 85 System.out.println( " getParent: " + f.getParent() ); 86 break; 87 case 15: 88 System.out.println( " lastModified: " + sdf.format( new Date( f.lastModified() ))); 89 break; 90 case 16: 91 System.out.println( "getDiskFreeSpace: " + f.getDiskFreeSpace() ); 92 break; 93 case 17: 94 System.out.println( " getDate: " + sdf.format( new Date( f.getDate() ))); 95 break; 96 case 18: 97 System.out.println( "getContentLength: " + f.getContentLength() ); 98 break; 99 case 19: 100 System.out.println( "getCanonicalPath: " + f.getCanonicalPath() ); 101 break; 102 case 20: 103 System.out.println( " exists: " + f.exists() ); 104 break; 105 case 21: 106 System.out.println( " canRead: " + f.canRead() ); 107 break; 108 case 22: 109 System.out.println( " canWrite: " + f.canWrite() ); 110 break; 111 case 23: 112 ACE[] security = f.getSecurity(true); 113 System.out.println( " Security:" ); 114 for (int ai = 0; ai < security.length; ai++) { 115 System.out.println(security[ai].toString()); 116 } 117 System.out.println(" Share Perm:"); 118 security = f.getShareSecurity(true); 119 for (int ai = 0; ai < security.length; ai++) { 120 System.out.println(security[ai].toString()); 121 } 122 break; 123 case 24: 124 System.out.println( " getDfsPath: " + f.getDfsPath() ); 125 break; 126 } 127 i++; 128 if( i == 25 ) { 129 i = 0; 130 } 131 } while( i != end ); 132 } 133 } 134 135 | Popular Tags |