com.hierynomus.mssmb2.SMB2ShareAccess Java Examples

The following examples show how to use com.hierynomus.mssmb2.SMB2ShareAccess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Samba2FileSystem.java    From iaf with Apache License 2.0 8 votes vote down vote up
@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;
}
 
Example #2
Source File: SMBJController.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
/**
 * get smb file, just need reed permission
 *
 * @param share    share
 * @param filePath file path not share name
 * @return smb file
 */
private File openFile(DiskShare share, String filePath) {
    return share.openFile(filePath,
            EnumSet.of(AccessMask.FILE_READ_DATA),
            null,
            SMB2ShareAccess.ALL,
            FILE_OPEN,
            null);
}
 
Example #3
Source File: SMBJ_RPCController.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
/**
 * get smb file, just need reed permission
 *
 * @param share    share
 * @param filePath file path not share name
 * @return smb file
 */
private File openFile(DiskShare share, String filePath) {
    return share.openFile(filePath,
            EnumSet.of(AccessMask.FILE_READ_DATA),
            null,
            SMB2ShareAccess.ALL,
            FILE_OPEN,
            null);
}
 
Example #4
Source File: SMBJController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * get smb directory, just need reed permission
 *
 * @param share    share
 * @param filePath directory path not share name
 * @return smb directory
 */
private Directory openDirectory(DiskShare share, String filePath) {
    return share.openDirectory(
            filePath,
            EnumSet.of(AccessMask.GENERIC_READ),
            null,
            SMB2ShareAccess.ALL,
            SMB2CreateDisposition.FILE_OPEN,
            null);
}
 
Example #5
Source File: SMBJController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * get smb disk entry, just need reed permission
 *
 * @param share    share
 * @param filePath file or directory path nor share name
 * @return dis entry
 */
private DiskEntry openDiskEntry(DiskShare share, String filePath) {
    return share.open(
            filePath,
            EnumSet.of(AccessMask.GENERIC_READ),
            null,
            SMB2ShareAccess.ALL,
            FILE_OPEN,
            null);
}
 
Example #6
Source File: SMBJ_RPCController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * get smb directory, just need read permission
 *
 * @param share    share
 * @param filePath directory path not share name
 * @return smb directory
 */
private Directory openDirectory(DiskShare share, String filePath) {
    return share.openDirectory(
            filePath,
            EnumSet.of(AccessMask.GENERIC_READ),
            null,
            SMB2ShareAccess.ALL,
            SMB2CreateDisposition.FILE_OPEN,
            null);
}
 
Example #7
Source File: SMBJ_RPCController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * get smb disk entry, just need reed permission
 *
 * @param share    share
 * @param filePath file or directory path nor share name
 * @return dis entry
 */
private DiskEntry openDiskEntry(DiskShare share, String filePath) {
    return share.open(
            filePath,
            EnumSet.of(AccessMask.GENERIC_READ),
            null,
            SMB2ShareAccess.ALL,
            FILE_OPEN,
            null);
}
 
Example #8
Source File: Samba2FileSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: Samba2FileSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: SMB2Utils.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
static DiskEntry open(DiskShare share, String path, Set<AccessMask> accessMask, SMB2CreateDisposition createDisposition) throws IOException {
	// use SMB2ShareAccess.ALL to prevent TimeoutException / buffer underflow on concurrent operations
	return share.open(path, accessMask, null, SMB2ShareAccess.ALL, createDisposition, null);
}