/usr/share/doc/libjcifs-java/examples/VerifyReads.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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | import java.net.MalformedURLException;
import jcifs.smb.*;
import java.io.*;
public class VerifyReads {
int maxDepth;
byte[] buf = new byte[8192];
VerifyReads( int maxDepth ) {
this.maxDepth = maxDepth;
}
void mkdir( File dir ) {
if( dir != null && !dir.exists() ) {
mkdir( dir.getParentFile() );
dir.mkdir();
}
}
void copy( SmbFile f, String path, int depth ) throws MalformedURLException, IOException {
int i, d;
File localFile, dir;
SmbFile[] list;
if( depth == 0 ) {
return;
}
localFile = new File( path + "/" + f.getName() );
d = f.getName().lastIndexOf( '.' );
if( f.isDirectory() ) {
list = f.listFiles();
for( i = 0; i < list.length; i++ ) {
copy( list[i], path + "/" + f.getName(), depth - 1 );
}
} else if( d > 1 && f.getName().substring( d ).equalsIgnoreCase( ".ini" )) {
mkdir( new File( path ));
SmbFileInputStream in = new SmbFileInputStream( f );
FileOutputStream out = new FileOutputStream( localFile );
while(( i = in.read( buf )) > 0 ) {
out.write( buf, 0, i );
}
in.close();
out.close();
}
}
public static void main(String[] argv) throws Exception {
VerifyReads cd;
SmbFile top;
int depth;
if( argv.length < 2 ) {
System.err.println( "Must specify ini directory location (e.g. smb://mydom\\;user:pass@nyc-19b9/apps) followd by the maximum traversal depth");
System.exit( 1 );
}
depth = Integer.parseInt( argv[1] );
cd = new VerifyReads( depth );
top = new SmbFile( argv[0] );
if( !top.isDirectory() ) {
System.err.println( "The path specified is not a directory" );
System.exit( 1 );
}
cd.copy( top, ".", depth );
}
}
|