@Override public Boolean call() { try { return file.exists(); } catch (final SmbException e) { return Boolean.FALSE; } } }).call(timeout).booleanValue();
@Override public boolean exists() { // Unlike java.io.File, SmbFile.exists() can throw an SmbException try { return file.exists(); } catch(IOException e) { LOGGER.info("Exception caught while calling SmbFile#exists(): " + e.getMessage()); return e instanceof SmbAuthException; } }
/** * Tests to see if the file this <code>SmbFile</code> represents is not a directory. * * @return <code>true</code> if this <code>SmbFile</code> is not a directory */ public boolean isFile() throws SmbException { if( getUncPath0().length() == 1 ) { return false; } exists(); return ( attributes & ATTR_DIRECTORY ) == 0; }
/** * Checks whether the remote resource exists. * @param _path remote path * @return true if exists, false otherwise * @throws IOException on error conditions returned by a CIFS server */ @Override public boolean exists(String _path) throws IOException { return createSmbFileObject(_path).exists(); }
@Override public boolean canRead () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents is a directory. * * @return <code>true</code> if this <code>SmbFile</code> is a directory */ public boolean isDirectory() throws SmbException { if( getUncPath0().length() == 1 ) { return true; } if (!exists()) return false; return ( attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY; }
/** * Tests to see if the file this <code>SmbFile</code> represents is a directory. * * @return <code>true</code> if this <code>SmbFile</code> is a directory */ public boolean isDirectory() throws SmbException { if( getUncPath0().length() == 1 ) { return true; } if (!exists()) return false; return ( attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY; }
@Override public int getAttributes () throws SmbException { if ( this.fileLocator.isRootOrShare() ) { return 0; } exists(); return this.attributes & ATTR_GET_MASK; }
@Override public boolean canRead () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
@Override public boolean isDirectory () throws SmbException { if ( this.fileLocator.isRootOrShare() ) { return true; } if ( !exists() ) return false; return ( this.attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY; }
@Override public boolean isFile () throws SmbException { if ( this.fileLocator.isRootOrShare() ) { return false; } exists(); return ( this.attributes & ATTR_DIRECTORY ) == 0; }
@Override public long lastModified () throws SmbException { if ( !this.fileLocator.isRootOrShare() ) { exists(); return this.lastModified; } return 0L; }
/** * Tests to see if the file this <code>SmbFile</code> represents is not a directory. * * @return <code>true</code> if this <code>SmbFile</code> is not a directory */ public boolean isFile() throws SmbException { if( getUncPath0().length() == 1 ) { return false; } exists(); return ( attributes & ATTR_DIRECTORY ) == 0; }
@Override public long lastModified () throws SmbException { if ( !this.fileLocator.isRootOrShare() ) { exists(); return this.lastModified; } return 0L; }
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password"); SmbFile smbFile = new SmbFile("//path", auth); InputStream in; if (smbFile.exists()) { in = smbFile.getInputStream(); }
/** * Checks whether the remote resource is a file. * @param _path remote path * @return true if resource is a file, false otherwise * @throws IOException on error conditions returned by a CIFS server */ public boolean isFile(String _path) throws IOException { SmbFile resource = createSmbFileObject(_path); return resource.exists() && resource.isFile(); }
void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException { int f, dir; exists(); dir = attributes & ATTR_DIRECTORY; f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES, dir, dir != 0 ? 0x0001 : 0x0040 ); send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ), new Trans2SetFileInformationResponse() ); close( f, 0L ); attrExpiration = 0; }
void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException { int f, dir; exists(); dir = attributes & ATTR_DIRECTORY; f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES, dir, dir != 0 ? 0x0001 : 0x0040 ); send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ), new Trans2SetFileInformationResponse() ); close( f, 0L ); attrExpiration = 0; }
void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException { int f, dir; exists(); dir = attributes & ATTR_DIRECTORY; f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES, dir, dir != 0 ? 0x0001 : 0x0040 ); send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ), new Trans2SetFileInformationResponse() ); close( f, 0L ); attrExpiration = 0; }
void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException { int f, dir; exists(); dir = attributes & ATTR_DIRECTORY; f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES, dir, dir != 0 ? 0x0001 : 0x0040 ); send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ), new Trans2SetFileInformationResponse() ); close( f, 0L ); attrExpiration = 0; }