[jcifs] Patch: Support for files > 4 GB
Thomas Krammer
TKrammer at nxn-software.com
Fri Jan 17 07:22:56 EST 2003
Hi,
I've updated jCIFS 0.7.1 to use 64bit offsets in SmbFileOutputStream. I've
tested an upload of a 7 GB file and it worked fine. The SmbFileInputStream
already used 64 bit offsets.
Here are my changes:
*** jcifs_0.7.1\src\jcifs\smb\SmbFileOutputStream.java Wed Jan 15 21:56:44
2003
--- jcifs_0.7.1_mod\src\jcifs\smb\SmbFileOutputStream.java Thu Jan 16
15:52:30 2003
***************
*** 32,38 ****
private SmbFile file;
private boolean append;
! private int openFlags, fp, writeSize;
private byte[] tmp = new byte[1];
/**
--- 32,39 ----
private SmbFile file;
private boolean append;
! private int openFlags, writeSize;
! private long fp;
private byte[] tmp = new byte[1];
/**
***************
*** 100,108 ****
this.openFlags = openFlags;
if( append ) {
try {
! fp = (int)file.length();
} catch( SmbException se ) {
! fp = 0;
}
}
file.open( openFlags );
--- 101,109 ----
this.openFlags = openFlags;
if( append ) {
try {
! fp = file.length();
} catch( SmbException se ) {
! fp = 0L;
}
}
file.open( openFlags );
***************
*** 160,166 ****
if( file.isOpen() == false ) {
file.open( openFlags );
if( append ) {
! fp = (int)file.length();
}
}
--- 161,167 ----
if( file.isOpen() == false ) {
file.open( openFlags );
if( append ) {
! fp = file.length();
}
}
*** jcifs_0.7.1\src\jcifs\smb\SmbComWriteAndX.java Wed Jan 15 21:56:44
2003
--- jcifs_0.7.1_mod\src\jcifs\smb\SmbComWriteAndX.java Thu Jan 16 18:00:58
2003
***************
*** 29,36 ****
static final int CLOSE_BATCH_LIMIT =
Config.getInt(
"jcifs.smb.client.WriteAndX.Close", 1 );
int fid,
- offset,
writeMode,
remaining,
dataLength,
--- 29,36 ----
static final int CLOSE_BATCH_LIMIT =
Config.getInt(
"jcifs.smb.client.WriteAndX.Close", 1 );
+ long offset;
int fid,
writeMode,
remaining,
dataLength,
***************
*** 42,48 ****
super( null );
command = SMB_COM_WRITE_ANDX;
}
! SmbComWriteAndX( int fid, int offset, int remaining,
byte[] b, int off, int len, ServerMessageBlock andx )
{
super( andx );
this.fid = fid;
--- 42,48 ----
super( null );
command = SMB_COM_WRITE_ANDX;
}
! SmbComWriteAndX( int fid, long offset, int remaining,
byte[] b, int off, int len, ServerMessageBlock andx )
{
super( andx );
this.fid = fid;
***************
*** 54,60 ****
command = SMB_COM_WRITE_ANDX;
}
! void setParam( int fid, int offset, int remaining,
byte[] b, int off, int len ) {
this.fid = fid;
this.offset = offset;
--- 54,60 ----
command = SMB_COM_WRITE_ANDX;
}
! void setParam( int fid, long offset, int remaining,
byte[] b, int off, int len ) {
this.fid = fid;
this.offset = offset;
***************
*** 75,81 ****
int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
int start = dstIndex;
! dataOffset = dstIndex + 22; // 22 = off from here to pad
/*
* pad = ( dataOffset - headerStart ) % 4;
* pad = pad == 0 ? 0 : 4 - pad;
--- 75,81 ----
int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
int start = dstIndex;
! dataOffset = dstIndex + 26; // 26 = off from here to pad
/*
* pad = ( dataOffset - headerStart ) % 4;
* pad = pad == 0 ? 0 : 4 - pad;
***************
*** 84,90 ****
writeInt2( fid, dst, dstIndex );
dstIndex += 2;
! writeInt4( offset, dst, dstIndex );
dstIndex += 4;
for( int i = 0; i < 4; i++ ) {
dst[dstIndex++] = (byte)0x00;
--- 84,90 ----
writeInt2( fid, dst, dstIndex );
dstIndex += 2;
! writeInt4( offset & 0xFFFFFFFFL, dst, dstIndex );
dstIndex += 4;
for( int i = 0; i < 4; i++ ) {
dst[dstIndex++] = (byte)0x00;
***************
*** 99,105 ****
dstIndex += 2;
writeInt2( dataOffset, dst, dstIndex );
dstIndex += 2;
! // offsetHigh another day
return dstIndex - start;
}
--- 99,106 ----
dstIndex += 2;
writeInt2( dataOffset, dst, dstIndex );
dstIndex += 2;
! writeInt4(( offset >> 32 ) & 0xFFFFFFFFL, dst, dstIndex );
! dstIndex += 4;
return dstIndex - start;
}
More information about the jcifs
mailing list