[jcifs] Some additions to SmbFile.java

The DJ hartman at mac.com
Thu Oct 18 01:11:13 EST 2001


Whoopsy,
I made a boo boo.  ;-)

You have to check for canonicalPath, or all directories are shares aswell.
CanonicalPath can also be used to adapt isDirectory(). Trivial of course.

DJ

/**
 * Tests to see if the file this <code>SmbFile</code> represents is a Share.
 *
 * @return <code>true</code> if this <code>SmbFile</code> is a Share
 */

    public boolean isShare() {
            if (this.exists() && this.isDirectory() ) {
                if  ( url.share != null && url.canonicalPath == null)
                    return true;
            }
            return false;
    }
        


> Since there already is a isWorkgroup method in SmbFile.java, I suggest to
> add the following:
> 
> /**
> * Tests to see if the file this <code>SmbFile</code> represents is a Share.
> *
> * @return <code>true</code> if this <code>SmbFile</code> is a Share
> */
> 
>   public boolean isShare() {
>           if (this.exists() && this.isDirectory() ) {
>                if  ( url.share != null)
>                   return true;
>           }
>           return false;
>   }
>       
> /**
> * Tests to see if the file this <code>SmbFile</code> represents is a
> Server.
> *
> * @return <code>true</code> if this <code>SmbFile</code> is a Server
> */
> 
>   public boolean isServer() {
>           if (this.exists() && this.isDirectory() ) {
>               if  ( url.share == null && url.server != null)
>                   return true;
>           }
>           return false;
>   }   
> 
> 
> 
> Be aware that a share and a server remain to respond positive to
> .isDirectory() as they do in the current implementation
> Maybe that should be changed aswell. That would obviously affect the above
> methods, in that isDirectory() should have to be negative.
> 
> I personally need this because I'm building a client and I use graphics in
> my listing to represent the kind of service I'm listing.


---------------------------------------------------------------------------
Universiteit Twente
---------------------------------------------------------------------------
Derk-Jan 'The DJ' Hartman
ICQnr: 10111559
Mail:  mailto:hartman at mac.com
WWW:   http://home.student.utwente.nl/d.hartman/
Goto:  http://www.student.utwente.nl/~macsatcampus





More information about the jcifs mailing list