/usr/share/doc/libjcifs-java/examples/SmbCrawler.java is in libjcifs-java-doc 1.3.19-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import jcifs.smb.SmbFile;
import java.util.LinkedList;
import java.util.ListIterator;
import java.net.MalformedURLException;
import java.io.IOException;
public class SmbCrawler {
int maxDepth;
SmbCrawler( int maxDepth ) {
this.maxDepth = maxDepth;
}
void traverse( SmbFile f, int depth ) throws MalformedURLException, IOException {
if( depth == 0 ) {
return;
}
SmbFile[] l = f.listFiles();
for(int i = 0; l != null && i < l.length; i++ ) {
try {
for( int j = maxDepth - depth; j > 0; j-- ) {
System.out.print( " " );
}
System.out.println( l[i] + " " + l[i].exists() );
if( l[i].isDirectory() ) {
traverse( l[i], depth - 1 );
}
} catch( IOException ioe ) {
System.out.println( l[i] + ":" );
ioe.printStackTrace( System.out );
}
}
}
public static void main(String[] argv) throws Exception {
int depth = Integer.parseInt( argv[1] );
SmbCrawler sc = new SmbCrawler( depth );
sc.traverse( new SmbFile( argv[0] ), depth );
}
}
|