[jcifs] Re: SmbFile constructor

Michael B Allen mba2000 at ioplex.com
Tue Aug 10 21:54:52 GMT 2004

Michael B Allen said:
> Eric Glass said:
>> Mike,
>> I'm looking for a constructor like:
>>     public SmbFile(SmbFile context, String name, int shareAccess);
>> The closest we appear to have is:
>>     public SmbFile(String context, String name,
>>             NtlmPasswordAuthentication auth, int shareAccess);
>> Which would be okay, except given an SmbFile there's no public way to
>> extract the "auth" member.  So I want to create an SmbFile relative to
>> the context, with a specific shareAccess, with the same NPA as the
>> context.  Currently, I think the only way to do this is to get the
>> "auth" member from the context file via reflection (kludgy), and then
>> use the constructor above.  Any thoughts?
> I added the necessary constructor. Also, you sent a patch for the Filter
> to be completely stateless (or something to that effect) but I am having
> trouble locating it. Can you retransmit so I can have a look-see.

Also, here's the constructor. It compiles but perhaps you can verify it
does what it's supposed to before I release?

    public SmbFile( SmbFile context, String name, int shareAccess )
                    throws MalformedURLException, UnknownHostException {
        this( context.isWorkgroup0() ?
            new URL( null, "smb://" + name, Handler.SMB_HANDLER ) :
            new URL( context.url, name, Handler.SMB_HANDLER ),
context.auth );
        if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE |
            throw new RuntimeException( "Illegal shareAccess parameter" );
        this.shareAccess = shareAccess;


More information about the jcifs mailing list