<div dir="ltr"><div>Hello,</div><div><br></div><div>I was trying to use 'SmbRandomAccessFile' class with mode value "r" for reading some file data, but it was not working. From the source code, it appears that for mode value "r", the 'access' value remains set to '0', and hence this problem. I had to modify the code as below to make it working. </div>
<div><br></div><div>BTW, what is the meaning of 'WRITE_OPTIONS' value as '0x0842' (as I do not see any description in the code), and I see the default zero value is being converted to '0x0040' later in the code?</div>
<div><br></div><div>-----------------Original code v1.3.17--------------</div><div>    private static final int WRITE_OPTIONS = 0x0842;</div><div>    ........</div><div>    private int openFlags, access = 0, readSize, writeSize, ch, options = 0;</div>
<div>    ......</div><div><span class="" style="white-space:pre">   </span></div><div>    public SmbRandomAccessFile( SmbFile file, String mode )</div><div>            throws SmbException, MalformedURLException, UnknownHostException {</div>
<div>        this.file = file;</div><div>        if( mode.equals( "r" )) {</div><div>            this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDONLY;</div><div>        } else if( mode.equals( "rw" )) {</div>
<div>            this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDWR | SmbFile.O_APPEND;</div><div>            write_andx_resp = new SmbComWriteAndXResponse();</div><div>            options = WRITE_OPTIONS;</div><div>            access = SmbConstants.FILE_READ_DATA | SmbConstants.FILE_WRITE_DATA;</div>
<div>        } else {</div><div>            throw new IllegalArgumentException( "Invalid mode" );</div><div>        }</div><div>        .........</div><div>    }</div><div>-----------------Modified code----------------------------------</div>
<div>    ........</div><div><span class="" style="white-space:pre"> </span></div><div>    public SmbRandomAccessFile( SmbFile file, String mode )</div><div>            throws SmbException, MalformedURLException, UnknownHostException {</div>
<div>        this.file = file;</div><div>        if( mode.equals( "r" )) {</div><div>            this.openFlags = SmbFile.O_RDONLY;</div><div>            access = SmbConstants.FILE_READ_DATA;</div><div>        } else if( mode.equals( "rw" )) {</div>
<div>            this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDWR | SmbFile.O_APPEND;</div><div>            write_andx_resp = new SmbComWriteAndXResponse();</div><div>            options = WRITE_OPTIONS;</div><div>            access = SmbConstants.FILE_READ_DATA | SmbConstants.FILE_WRITE_DATA;</div>
<div>        } else {</div><div>            throw new IllegalArgumentException( "Invalid mode" );</div><div>        }</div><div>-------------------------------------------------------------------</div><div><br></div>
<div>Many thanks for providing this library free of cost.</div><div><br></div><div>Beast regards,</div><div>Somnath Kundu</div></div>