[jcifs] RE: [Fwd: SmbTree copy()]

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Tue Oct 30 15:21:52 EST 2001


Yikes. What does this program do? It's endless Node Status and Trans2QueryInformation requests.

> From: Rob Wygand <rob at filefish.com>
> To: jcifs at samba.org
> 
> Mike,
> 
> A while back you mentioned that SmbTree had a function called copy() 
> that was commented out. While I know that it's not supported, I wanted 
> to get some input from you.
> 
> I renamed SmbComCopy.jav and SmbComCopyResponse.jav to *.java and 
> uncommented the SmbTree.copy() function. It originally took an int tid2, 
> 
	You difinately need tid2. It has to be the tree id of the tree (a.k.a. share) that the other file is in. But from examining the below it should work because the shares (and therefore tids) are
the same. It's possible that the packet encoding isn't quite right since the last time this method was used. Try useUnicode=false just as an exercise. I think you'd really need to break out Ethereal
or NetMon and just compare each field byte for byte. THat's what I would do.

> which I removed from the function decl and instead use the tid in 
> SmbTree itself (this might be a problem, but I've tried various things 
> here and none seem to work). Smbtree.copy looks like:
> 
	...
>        send( new SmbComCopy( sourceFileName, targetFileName, tid ), 
	...

> Then I added the following function to SmbFile:
> 
>    public boolean copyTo (SmbFile dest)
>      throws IOException, SmbException {
>      if( dest.exists() ) {
>        // otherwise we get Access Denied
>        if(( dest.attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY ) {
>          Log.println( Log.WARNINGS, "SmbFile warning",
>                       " cannot copyTo() a directory that exists: " +
>                       dest.getName() );
>          return false;
>        }
> 
>        if( dest.delete() == false ) {
>          return false;
>        }
>      }
>      return tree.copy ( path, dest.path );
>    }
> 
	Yeah, this all should work. It looks right. PS you can easily get tid2 from dest.tree.tid. Then, presuming, you get it working you can also do copies accross shares without going through the
client. If I have time, maybe I'll look into fixing this.

> I've attached the debug logs to this email. I was attempting to copy a 
> file from
> smb://ocean/bigfish/Users/rob/ApacheModules.doc to 
> smb://ocean/bigfish/Users/test/ApacheModules.doc. At line 275 of the log 
> you can see the contents of the SMB_COM_COPY packet, and following it is 
> the result, which has an errorCode of ERRDOS/ERRbadpath.
> 
	That 'test' directory exists right?

	Mike





More information about the jcifs mailing list