use of com.hierynomus.smbj.share.File in project iaf by ibissource.
the class Samba2FileSystem method moveFile.
@Override
public String moveFile(String f, String destinationFolder, boolean createFolder) throws FileSystemException {
try (File file = getFile(f, AccessMask.GENERIC_ALL, SMB2CreateDisposition.FILE_OPEN)) {
String destination = toFile(destinationFolder, f);
file.rename(destination, false);
return destination;
}
}
use of com.hierynomus.smbj.share.File in project iaf by ibissource.
the class Samba2FileSystem method appendFile.
@Override
public OutputStream appendFile(String f) throws FileSystemException, IOException {
final File file = getFile(f, AccessMask.FILE_APPEND_DATA, SMB2CreateDisposition.FILE_OPEN_IF);
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;
}
use of com.hierynomus.smbj.share.File 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;
}
use of com.hierynomus.smbj.share.File 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;
}
use of com.hierynomus.smbj.share.File 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;
}
Aggregations