Search in sources :

Example 6 with File

use of com.hierynomus.smbj.share.File in project iaf by ibissource.

the class Samba2FileSystem method getFile.

private File getFile(String filename, AccessMask accessMask, SMB2CreateDisposition createDisposition) {
    Set<SMB2ShareAccess> shareAccess = new HashSet<SMB2ShareAccess>();
    shareAccess.addAll(SMB2ShareAccess.ALL);
    Set<SMB2CreateOptions> createOptions = new HashSet<SMB2CreateOptions>();
    createOptions.add(SMB2CreateOptions.FILE_WRITE_THROUGH);
    Set<AccessMask> accessMaskSet = new HashSet<AccessMask>();
    accessMaskSet.add(accessMask);
    File file;
    file = diskShare.openFile(filename, accessMaskSet, null, shareAccess, createDisposition, createOptions);
    return file;
}
Also used : SMB2CreateOptions(com.hierynomus.mssmb2.SMB2CreateOptions) SMB2ShareAccess(com.hierynomus.mssmb2.SMB2ShareAccess) AccessMask(com.hierynomus.msdtyp.AccessMask) File(com.hierynomus.smbj.share.File) HashSet(java.util.HashSet)

Example 7 with File

use of com.hierynomus.smbj.share.File in project iaf by ibissource.

the class Samba2FileSystemTestHelper method _readFile.

@Override
public InputStream _readFile(String folder, String filename) throws Exception {
    final File file = getFile(filename, AccessMask.GENERIC_READ, SMB2CreateDisposition.FILE_OPEN);
    InputStream is = file.getInputStream();
    FilterInputStream fis = new FilterInputStream(is) {

        boolean isOpen = true;

        @Override
        public void close() throws IOException {
            if (isOpen) {
                super.close();
                isOpen = false;
            }
            file.close();
        }
    };
    return fis;
}
Also used : FilterInputStream(java.io.FilterInputStream) FilterInputStream(java.io.FilterInputStream) InputStream(java.io.InputStream) File(com.hierynomus.smbj.share.File)

Aggregations

File (com.hierynomus.smbj.share.File)7 AccessMask (com.hierynomus.msdtyp.AccessMask)4 SMB2CreateOptions (com.hierynomus.mssmb2.SMB2CreateOptions)4 HashSet (java.util.HashSet)4 FilterOutputStream (java.io.FilterOutputStream)3 OutputStream (java.io.OutputStream)3 SMB2ShareAccess (com.hierynomus.mssmb2.SMB2ShareAccess)2 FilterInputStream (java.io.FilterInputStream)1 InputStream (java.io.InputStream)1