This file is indexed.

/usr/share/doc/libjcifs-java/examples/FileOpsRenameTo.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
78
79
80
81
82
83
84
/* Test the following file operations:
 * 
 * canRead
 *     false - a target that is already open by another process
 *     false - the target does not exist
 *     true  - the file exists and there are no sharing issues
 * canWrite
 *     true  - the file exists and there are no sharing issues
 *     false - the file is marked read-only
 *     false - the file does not exist
 * delete
 *     true  - the file existed and was succcessfully deleted
 *     false - the target did not exist
 *     false - the target is a share, server, workgroup or similar
 *     false - the target or file under the target directory failed was read-only
 * exists
 *     true  - the target, share, IPC share, named pipe, server, or workgroup exists
 *     false - the opposite of the above
 * isDirectory
 *     true  - the target is a workgroup, server, share, or directory
 *     false - the target is not one of the above or does not exist
 * isFile
 *     direct opposite of isDirectory
 * isHidden
 *     true  - target is share ending in $ or marked as hidden
 * length
 *     the file was created to be no larger than ~2G and reports back the size specified
 * mkdir
 *     true  - a directory was created successfuly
 *     false - the directory could not be created
 * renameTo
 *     true  - the target was renamed
 */

import jcifs.smb.*;
import java.io.IOException;
import java.util.Date;

public class FileOpsRenameTo {

    static final int ATTR_ALL = SmbFile.ATTR_ARCHIVE | SmbFile.ATTR_HIDDEN | SmbFile.ATTR_READONLY | SmbFile.ATTR_SYSTEM;

    public static void main( String argv[] ) throws Exception {

        if( argv.length != 1 ) {
            System.out.println( "Must provide an SMB URL of a remote location on which tests will be conducted." );
            System.exit( 1 );
        }

        SmbFile s = new SmbFile( argv[0] );
        SmbFile d = new SmbFile( s, "JcifsTestOpsDir/" );

    // Create a file to test against

    SmbFile f = null;
    try {
        f = new SmbFile( d, "foo.txt" );
        SmbFileOutputStream o = new SmbFileOutputStream( f );
        o.write( "The Common Internet File System (CIFS) is the de-facto file sharing protocol on the Microsoft Windows platform. It is the underlying networking protocol used when accessing shares with Windows Explorer, the Network Neighborhood, via a Map Network Drive...  dialog, the C:\\> net use * \\\\server\\share commands, or smbclient on UNIX, smbfs on Linux, and elsewhere.\r\n".getBytes() );
        o.close();
    } catch( IOException ioe ) {
        System.out.println( "fail - could not create file " + d + "foo.txt: " + ioe.getMessage() );
    }
    System.out.println( "okay - created file " + d + "foo.txt" );

    // renameTo - rename the file to bar.txt

        SmbFile b = new SmbFile( d, "bar.txt" );

        try {
            f.renameTo( b );
            System.out.println( "okay - renameTo " + f + " to " + b + " successful even with read-only" );
            try {
                b.renameTo(f);
            } catch( SmbException se ) {
                System.out.println( "fail - but failed to rename file back to original!" );
                throw se;
            }
        } catch( SmbException se ) {
            se.printStackTrace();
        }

    }
}