public void close() { share.closeFileId(fileId); }
public void deleteOnClose() { share.deleteOnClose(fileId); }
/** * File in the given path exists or not */ public boolean fileExists(String path) throws SMBApiException { return exists(path, of(FILE_NON_DIRECTORY_FILE), FILE_EXISTS_STATUS_HANDLER); }
private SMB2CreateResponseContext resolveAndCreateFile(SmbPath path, SMB2ImpersonationLevel impersonationLevel, Set<AccessMask> accessMask, Set<FileAttributes> fileAttributes, Set<SMB2ShareAccess> shareAccess, SMB2CreateDisposition createDisposition, Set<SMB2CreateOptions> createOptions) { try { SmbPath target = resolver.resolve(session, path); DiskShare resolvedShare = rerouteIfNeeded(path, target); return resolvedShare.createFileAndResolve(target, impersonationLevel, accessMask, fileAttributes, shareAccess, createDisposition, createOptions); } catch (PathResolveException pre) { throw new SMBApiException(pre.getStatus().getValue(), SMB2MessageCommandCode.SMB2_CREATE, "Cannot resolve path " + path, pre); } }
public DiskEntry open(String path, Set<AccessMask> accessMask, Set<FileAttributes> attributes, Set<SMB2ShareAccess> shareAccesses, SMB2CreateDisposition createDisposition, Set<SMB2CreateOptions> createOptions) { SmbPath pathAndFile = new SmbPath(smbPath, path); SMB2CreateResponseContext response = resolveAndCreateFile(pathAndFile, null, accessMask, attributes, shareAccesses, createDisposition, createOptions); return getDiskEntry(path, response); }
public InputStream getInputStream(ProgressListener listener) { return new FileInputStream(this, share.getReadBufferSize(), share.getReadTimeout(), listener); }
/** * Get information about the given path. **/ public FileAllInformation getFileInformation(String path) throws SMBApiException { return getFileInformation(path, FileAllInformation.class); }
public void read(OutputStream destStream, ProgressListener progressListener) throws IOException { InputStream is = getInputStream(progressListener); int numRead; byte[] buf = new byte[share.getReadBufferSize()]; while ((numRead = is.read(buf)) != -1) { destStream.write(buf, 0, numRead); } is.close(); }
public void flush() { share.flush(fileId); }
share = new DiskShare(smbPath, treeConnect, pathResolver); } else if (response.isNamedPipe()) { share = new PipeShare(smbPath, treeConnect);
private SMB2CreateResponseContext resolveAndCreateFile(SmbPath path, SMB2ImpersonationLevel impersonationLevel, Set<AccessMask> accessMask, Set<FileAttributes> fileAttributes, Set<SMB2ShareAccess> shareAccess, SMB2CreateDisposition createDisposition, Set<SMB2CreateOptions> createOptions) { try { SmbPath target = resolver.resolve(session, path); DiskShare resolvedShare = rerouteIfNeeded(path, target); return resolvedShare.createFileAndResolve(target, impersonationLevel, accessMask, fileAttributes, shareAccess, createDisposition, createOptions); } catch (PathResolveException pre) { throw new SMBApiException(pre.getStatus().getValue(), SMB2MessageCommandCode.SMB2_CREATE, "Cannot resolve path " + path, pre); } }
public DiskEntry open(String path, Set<AccessMask> accessMask, Set<FileAttributes> attributes, Set<SMB2ShareAccess> shareAccesses, SMB2CreateDisposition createDisposition, Set<SMB2CreateOptions> createOptions) { SmbPath pathAndFile = new SmbPath(smbPath, path); SMB2CreateResponseContext response = resolveAndCreateFile(pathAndFile, null, accessMask, attributes, shareAccesses, createDisposition, createOptions); return getDiskEntry(path, response); }
public InputStream getInputStream(ProgressListener listener) { return new FileInputStream(this, share.getReadBufferSize(), share.getReadTimeout(), listener); }
/** * Get information about the given path. **/ public FileAllInformation getFileInformation(String path) throws SMBApiException { return getFileInformation(path, FileAllInformation.class); }
public void read(OutputStream destStream, ProgressListener progressListener) throws IOException { InputStream is = getInputStream(progressListener); int numRead; byte[] buf = new byte[share.getReadBufferSize()]; while ((numRead = is.read(buf)) != -1) { destStream.write(buf, 0, numRead); } is.close(); }
public void flush() { share.flush(fileId); }
share = new DiskShare(smbPath, treeConnect, pathResolver); } else if (response.isNamedPipe()) { share = new PipeShare(smbPath, treeConnect);
private SMB2CreateResponseContext createFileAndResolve(SmbPath path, SMB2ImpersonationLevel impersonationLevel, Set<AccessMask> accessMask, Set<FileAttributes> fileAttributes, Set<SMB2ShareAccess> shareAccess, SMB2CreateDisposition createDisposition, Set<SMB2CreateOptions> createOptions) { SMB2CreateResponse resp = super.createFile(path, impersonationLevel, accessMask, fileAttributes, shareAccess, createDisposition, createOptions); try { SmbPath target = resolver.resolve(session, resp, path); DiskShare resolveShare = rerouteIfNeeded(path, target); if (!path.equals(target)) { return resolveShare.createFileAndResolve(target, impersonationLevel, accessMask, fileAttributes, shareAccess, createDisposition, createOptions); } } catch (PathResolveException e) { throw new SMBApiException(e.getStatusCode(), SMB2MessageCommandCode.SMB2_CREATE, "Cannot resolve path " + path, e); } return new SMB2CreateResponseContext(resp, path, this); }
/** * Get information for a given fileId **/ public FileAllInformation getFileInformation(SMB2FileId fileId) throws SMBApiException { return getFileInformation(fileId, FileAllInformation.class); }
/** * Folder in the given path exists or not. */ public boolean folderExists(String path) throws SMBApiException { return exists(path, of(FILE_DIRECTORY_FILE), FOLDER_EXISTS_STATUS_HANDLER); }