Search in sources :

Example 1 with SMB2CreateOptions

use of com.hierynomus.mssmb2.SMB2CreateOptions in project iaf by ibissource.

the class Samba2FileSystem method createFile.

@Override
public OutputStream createFile(String f) throws FileSystemException, IOException {
    Set<AccessMask> accessMask = new HashSet<AccessMask>(EnumSet.of(AccessMask.FILE_ADD_FILE));
    Set<SMB2CreateOptions> createOptions = new HashSet<SMB2CreateOptions>(EnumSet.of(SMB2CreateOptions.FILE_NON_DIRECTORY_FILE, SMB2CreateOptions.FILE_WRITE_THROUGH));
    final File file = diskShare.openFile(f, accessMask, null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE_IF, createOptions);
    OutputStream out = file.getOutputStream();
    FilterOutputStream fos = new FilterOutputStream(out) {

        boolean isOpen = true;

        @Override
        public void close() throws IOException {
            if (isOpen) {
                super.close();
                isOpen = false;
            }
            file.close();
        }
    };
    return fos;
}
Also used : FilterOutputStream(java.io.FilterOutputStream) OutputStream(java.io.OutputStream) SMB2CreateOptions(com.hierynomus.mssmb2.SMB2CreateOptions) AccessMask(com.hierynomus.msdtyp.AccessMask) FilterOutputStream(java.io.FilterOutputStream) File(com.hierynomus.smbj.share.File) HashSet(java.util.HashSet)

Example 2 with SMB2CreateOptions

use of com.hierynomus.mssmb2.SMB2CreateOptions in project iaf by ibissource.

the class Samba2FileSystemTestHelper 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 3 with SMB2CreateOptions

use of com.hierynomus.mssmb2.SMB2CreateOptions in project iaf by ibissource.

the class Samba2FileSystemTestHelper method _createFile.

@Override
public OutputStream _createFile(String folder, String filename) throws Exception {
    Set<AccessMask> accessMask = new HashSet<AccessMask>(EnumSet.of(AccessMask.FILE_ADD_FILE));
    Set<SMB2CreateOptions> createOptions = new HashSet<SMB2CreateOptions>(EnumSet.of(SMB2CreateOptions.FILE_NON_DIRECTORY_FILE, SMB2CreateOptions.FILE_WRITE_THROUGH));
    final File file = diskShare.openFile(filename, accessMask, null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE_IF, createOptions);
    OutputStream out = file.getOutputStream();
    FilterOutputStream fos = new FilterOutputStream(out) {

        boolean isOpen = true;

        @Override
        public void close() throws IOException {
            if (isOpen) {
                super.close();
                isOpen = false;
            }
            file.close();
        }
    };
    return fos;
}
Also used : OutputStream(java.io.OutputStream) FilterOutputStream(java.io.FilterOutputStream) SMB2CreateOptions(com.hierynomus.mssmb2.SMB2CreateOptions) AccessMask(com.hierynomus.msdtyp.AccessMask) FilterOutputStream(java.io.FilterOutputStream) File(com.hierynomus.smbj.share.File) HashSet(java.util.HashSet)

Example 4 with SMB2CreateOptions

use of com.hierynomus.mssmb2.SMB2CreateOptions 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)

Aggregations

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