public void closeSilently() { try { close(); } catch (Exception e) { logger.warn("File close failed for {},{},{}", fileName, share, fileId, e); } } }
/** * Creates hard link for receiver.<br/> * This method is a shortcut for <code>DiskEntry#createHardlink(linkname, false)</code> * * @param linkname the path to the hard link relative to share * @throws SMBApiException * * @see {@link DiskEntry#createHardlink(String, boolean)} */ public void createHardlink(final String linkname) throws SMBApiException { this.createHardlink(linkname, false); }
public FileAllInformation getFileInformation() throws SMBApiException { return getFileInformation(FileAllInformation.class); }
public void rename(String newName, boolean replaceIfExist, long rootDirectory) throws SMBApiException { FileRenameInformation renameInfo = new FileRenameInformation(replaceIfExist, rootDirectory, newName); this.setFileInformation(renameInfo); }
public void rename(String newName) throws SMBApiException { this.rename(newName, false); }
/** * Remove the file at the given path */ public void rm(String path) throws SMBApiException { try (DiskEntry e = open( path, of(DELETE), of(FILE_ATTRIBUTE_NORMAL), of(FILE_SHARE_DELETE, FILE_SHARE_WRITE, FILE_SHARE_READ), FILE_OPEN, of(FILE_NON_DIRECTORY_FILE) )) { e.deleteOnClose(); } }
/** * The SecurityDescriptor(MS-DTYP 2.4.6 SECURITY_DESCRIPTOR) for the Given Path */ public SecurityDescriptor getSecurityInfo(String path, Set<SecurityInformation> securityInfo) throws SMBApiException { EnumSet<AccessMask> accessMask = of(READ_CONTROL); if (securityInfo.contains(SecurityInformation.SACL_SECURITY_INFORMATION)) { accessMask.add(ACCESS_SYSTEM_SECURITY); } try (DiskEntry e = open(path, accessMask, null, ALL, FILE_OPEN, null)) { return e.getSecurityInformation(securityInfo); } }
/** * The SecurityDescriptor(MS-DTYP 2.4.6 SECURITY_DESCRIPTOR) for the Given FileId */ public void setSecurityInfo(String path, Set<SecurityInformation> securityInfo, SecurityDescriptor securityDescriptor) throws SMBApiException { Set<AccessMask> accessMask = noneOf(AccessMask.class); if (securityInfo.contains(SecurityInformation.SACL_SECURITY_INFORMATION)) { accessMask.add(ACCESS_SYSTEM_SECURITY); } if (securityInfo.contains(SecurityInformation.OWNER_SECURITY_INFORMATION) || securityInfo.contains(SecurityInformation. GROUP_SECURITY_INFORMATION)) { accessMask.add(WRITE_OWNER); } if (securityInfo.contains(SecurityInformation.DACL_SECURITY_INFORMATION)) { accessMask.add(WRITE_DAC); } try (DiskEntry e = open(path, accessMask, null, ALL, FILE_OPEN, null)) { e.setSecurityInformation(securityDescriptor, securityInfo); } }
/** * Get information for a given path **/ public <F extends FileSettableInformation> void setFileInformation(String path, F information) throws SMBApiException { try (DiskEntry e = open(path, of(FILE_WRITE_ATTRIBUTES, FILE_WRITE_EA), null, ALL, FILE_OPEN, null)) { e.setFileInformation(information); } }
public void rename(String newName, boolean replaceIfExist) throws SMBApiException { this.rename(newName, replaceIfExist, 0); }
/** * Remove the file at the given path */ public void rm(String path) throws SMBApiException { try (DiskEntry e = open( path, of(DELETE), of(FILE_ATTRIBUTE_NORMAL), of(FILE_SHARE_DELETE, FILE_SHARE_WRITE, FILE_SHARE_READ), FILE_OPEN, of(FILE_NON_DIRECTORY_FILE) )) { e.deleteOnClose(); } catch (SMBApiException sae) { if (ALREADY_DELETED_STATUS_HANDLER.isSuccess(sae.getStatusCode())) { return; } throw sae; } }
/** * The SecurityDescriptor(MS-DTYP 2.4.6 SECURITY_DESCRIPTOR) for the Given Path */ public SecurityDescriptor getSecurityInfo(String path, Set<SecurityInformation> securityInfo) throws SMBApiException { EnumSet<AccessMask> accessMask = of(READ_CONTROL); if (securityInfo.contains(SecurityInformation.SACL_SECURITY_INFORMATION)) { accessMask.add(ACCESS_SYSTEM_SECURITY); } try (DiskEntry e = open(path, accessMask, null, ALL, FILE_OPEN, null)) { return e.getSecurityInformation(securityInfo); } }
/** * The SecurityDescriptor(MS-DTYP 2.4.6 SECURITY_DESCRIPTOR) for the Given FileId */ public void setSecurityInfo(String path, Set<SecurityInformation> securityInfo, SecurityDescriptor securityDescriptor) throws SMBApiException { Set<AccessMask> accessMask = noneOf(AccessMask.class); if (securityInfo.contains(SecurityInformation.SACL_SECURITY_INFORMATION)) { accessMask.add(ACCESS_SYSTEM_SECURITY); } if (securityInfo.contains(SecurityInformation.OWNER_SECURITY_INFORMATION) || securityInfo.contains(SecurityInformation. GROUP_SECURITY_INFORMATION)) { accessMask.add(WRITE_OWNER); } if (securityInfo.contains(SecurityInformation.DACL_SECURITY_INFORMATION)) { accessMask.add(WRITE_DAC); } try (DiskEntry e = open(path, accessMask, null, ALL, FILE_OPEN, null)) { e.setSecurityInformation(securityDescriptor, securityInfo); } }
/** * Get information for a given path **/ public <F extends FileSettableInformation> void setFileInformation(String path, F information) throws SMBApiException { try (DiskEntry e = open(path, of(FILE_WRITE_ATTRIBUTES, FILE_WRITE_EA), null, ALL, FILE_OPEN, null)) { e.setFileInformation(information); } }
public FileAllInformation getFileInformation() throws SMBApiException { return getFileInformation(FileAllInformation.class); }
public void rename(String newName) throws SMBApiException { this.rename(newName, false); }
of(FILE_DIRECTORY_FILE) )) { e.deleteOnClose();
/** * Creates hard link for receiver.<br/> * This method is a shortcut for <code>DiskEntry#createHardlink(linkname, false)</code> * * @param linkname the path to the hard link relative to share * @throws SMBApiException * * @see {@link DiskEntry#createHardlink(String, boolean)} */ public void createHardlink(final String linkname) throws SMBApiException { this.createHardlink(linkname, false); }
public void closeSilently() { try { close(); } catch (Exception e) { logger.warn("File close failed for {},{},{}", fileName, share, fileId, e); } } }
/** * Creates hard link for receiver. * * @param linkname the path to the hard link relative to share * @param replaceIfExist if true replaces existing entry. * * @throws SMBApiException */ public void createHardlink(final String linkname, final boolean replaceIfExist) throws SMBApiException { final FileLinkInformation linkInfo = new FileLinkInformation(replaceIfExist, linkname); this.setFileInformation(linkInfo); }