On Fri, Jun 01, 2012 at 01:39:48PM -0700, James Paige wrote:
> On Thu, May 31, 2012 at 11:23:40AM -0700, James Paige wrote:
> > On Thu, May 31, 2012 at 09:46:46AM -0700, James Paige wrote:
> > > On Thu, May 31, 2012 at 09:34:19AM -0700, James Paige wrote:
> > > > On Mon, May 21, 2012 at 03:23:39PM -0700, James Paige wrote:
> > > > > I was messing around with trying to make a simplified test case for 
> > > > > the 
> > > > > LOF bug. I never did figure out exactly what to type to compile a 
> > > > > simple 
> > > > > .bas file, but I discovered it was easy to just add another compile 
> > > > > target to SConscript using relump and unlump as my model.
> > > > > 
> > > > > I couldn't reproduce any oddness with LOF, but I did discover some 
> > > > > peculiar behavior when a file is opened BINARY ACCESS READ
> > > > > 
> > > > > The following code works perfectly on Linux, but on Mac, it fails to 
> > > > > read anything at all from the first two files. The third and fourth 
> > > > > file 
> > > > > work fine.
> > > > > 
> > > > > If you change
> > > > > - OPEN filename FOR BINARY ACCESS READ AS #fh
> > > > > + OPEN filename FOR BINARY AS #fh
> > > > > Then the code works perfectly on Mac.
> > > > > 
> > > > > ------------------------------------------------------
> > > > > 
> > > > > SUB test(filename as string)
> > > > >  DIM size as integer
> > > > >  DIM chunk as string = STRING(10, 0)
> > > > > 
> > > > >  DIM fh as integer = FREEFILE
> > > > > 
> > > > >  OPEN filename FOR BINARY ACCESS READ AS #fh
> > > > > 
> > > > >   PRINT filename
> > > > > 
> > > > >   '--Read and print the first 10 bytes
> > > > >   GET #fh, , chunk
> > > > >   PRINT "10bytes=""" & chunk & """"
> > > > > 
> > > > >  CLOSE #fh
> > > > > END SUB
> > > > > 
> > > > > 
> > > > > DIM testfiles(3) as string = {"README-game.txt", "README-custom.txt", 
> > > > > "whatsnew.txt", "IMPORTANT-nightly.txt"}
> > > > > 
> > > > > DIM size as integer
> > > > > FOR i as integer = 0 TO UBOUND(testfiles)
> > > > >  test testfiles(i)
> > > > > NEXT i
> > > > 
> > > > I was messing around some more with this same test case, and I realized 
> > > > I was wrong. it isn't that OPEN FILENAME FOR BINARY ACCESS READ fails 
> > > > for the first two opens, because I can rearrange the filenames, and the 
> > > > same filenames fail.
> > > > 
> > > > Why would the filename make a difference for whether or not data can be 
> > > > read from the file?
> > > 
> > > On further examination, it seems to be the contents of the file that 
> > > make a difference, not the filename.
> > > 
> > > Some files are read as all zeroes... some files are read normally.
> > > 
> > 
> > Another observation:
> > This bug apparently NEVER happens to any file >= 4096 bytes.
> > 
> > I still haven't figured out the rhyme or reason to which files < 4096 
> > bytes are affected.
> > 
> 
> Actually, I can't believe I missed this before, but it looks like ALL 
> files < 4096 bytes are affected. The filenames that have smaller sizes 
> that were not affected were actually the names of directories.
> 
> I am not sure why OPEN works at all on directories, but it does. The LOF 
> when opening a directory appears to be nonsense.
> 

When using the Linux version of FreeBasic, you can always successfully 
OPEN directories, and LOF is always 4096.

When using the Windows version of FreeBasic, attempting to OPEN a 
directory fails, as I would expect (although the docs at 
http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpen don't make it 
explicit what should happen in this case)

---
James
_______________________________________________
Ohrrpgce mailing list
[email protected]
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to