Search in sources :

Example 1 with AccessMask

use of com.hierynomus.msdtyp.AccessMask in project iaf by ibissource.

the class Samba2FileSystem method getFolder.

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

Example 2 with AccessMask

use of com.hierynomus.msdtyp.AccessMask 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 3 with AccessMask

use of com.hierynomus.msdtyp.AccessMask 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 4 with AccessMask

use of com.hierynomus.msdtyp.AccessMask 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 5 with AccessMask

use of com.hierynomus.msdtyp.AccessMask 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)6 HashSet (java.util.HashSet)6 SMB2CreateOptions (com.hierynomus.mssmb2.SMB2CreateOptions)4 SMB2ShareAccess (com.hierynomus.mssmb2.SMB2ShareAccess)4 File (com.hierynomus.smbj.share.File)4 Directory (com.hierynomus.smbj.share.Directory)2 FilterOutputStream (java.io.FilterOutputStream)2 OutputStream (java.io.OutputStream)2