• File object randomly thin

    From Nightfox@VERT/DIGDIST to All on Fri Jul 3 16:55:00 2009
    Hi all. I'm working on a JavaScript script for Synchronet - a logon matrix - and I've run into a weird issue with the File class.

    In my script, I want to open and read a configuration file that has options for the script. The problem is that the File object sometimes thinks the
    file is empty (length property is 0), and other times it is able to read the file without any problems. I can observe this just by running the script several times in a row.

    I'm wondering if it might have to do with the fact that I'm placing my script in a directory other than the SBBS exec directory. I'm using a trick in the code to determine the script's current directory, and the configuration file is in a subdirectory that's a couple levels deeper. I've been able to verify that the File object is indeed able to open the file (or at least thinks it's open); it just sometimes thinks the file's length is 0, and thus doesn't read anything from it.

    When I create the File object, the filename that will get passed to it is something along the lines of this: D:\BBS\sbbs\mods\../xtrn/DigDist\DDLoginMatrixThemes/kd-snake/DDMatrixThe me.cfg

    Is there a known bug related to what I'm describing? Might I simply be passing too long of a path to the File object?

    Nightfox


    ---
    þ Synchronet þ Digital Distortion BBS
  • From Digital Man@VERT to Nightfox on Fri Jul 3 19:39:00 2009
    Re: File object randomly thinks file is empty
    By: Nightfox to All on Fri Jul 03 2009 08:55 pm

    Hi all. I'm working on a JavaScript script for Synchronet - a logon matrix - and I've run into a weird issue with the File class.

    In my script, I want to open and read a configuration file that has options for the script. The problem is that the File object sometimes thinks the file is empty (length property is 0), and other times it is able to read
    the file without any problems. I can observe this just by running the script several times in a row.

    I'm wondering if it might have to do with the fact that I'm placing my script in a directory other than the SBBS exec directory. I'm using a
    trick in the code to determine the script's current directory, and the configuration file is in a subdirectory that's a couple levels deeper.
    I've been able to verify that the File object is indeed able to open the file (or at least thinks it's open); it just sometimes thinks the file's length is 0, and thus doesn't read anything from it.

    When I create the File object, the filename that will get passed to it is something along the lines of this: D:\BBS\sbbs\mods\../xtrn/DigDist\DDLoginMatrixThemes/kd-snake/DDMatrixThe me.cfg

    Is there a known bug related to what I'm describing? Might I simply be passing too long of a path to the File object?

    I don't know of any such problem. Are you checking the return value of File.open()? Is it possible that it's returning false sometimes and that's why the length would be 0? If you could post a small example script which demonstrates the problem, that would be helpful. I don't think the filename length or directory where the file is located is an issue.

    digital man

    Snapple "Real Fact" #160:
    One alternate title that had been considered for NBC's hit "Friends" was "Insomnia Cafe."

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Sat Jul 4 08:24:00 2009
    Re: File object randomly thinks file is empty
    By: Digital Man to Nightfox on Fri Jul 03 2009 23:39:40

    for the script. The problem is that the File object sometimes thinks file is empty (length property is 0), and other times it is able to re

    I don't know of any such problem. Are you checking the return value of File.open()? Is it possible that it's returning false sometimes and that' the length would be 0? If you could post a small example script which

    It looks like the problem was me. PEBCAC (Problem Exists Between Computer
    And Chair). :)
    One thing I'm doing with this script is having support for different
    "themes", which each theme in its own directory and having its own configuration file. I have my script choose a theme at random. Originally I had forgotten to pass an open mode to File.open(), and it looks like as it
    was opening files, it was stomping on them and wiping out all contents - so there were indeed files that were empty. I had meant to pass "r" as the
    open mode. I have re-created my configuration files, and it seems to work properly.

    So, nothing to see here, move along.. ;)

    Nightfox


    ---
    þ Synchronet þ Digital Distortion BBS
  • From Tracker1@VERT/TRN to Nightfox on Sat Jul 4 10:56:00 2009
    On 7/3/2009 8:55 PM, Nightfox wrote:
    Hi all. I'm working on a JavaScript script for Synchronet - a logon matrix -
    and I've run into a weird issue with the File class.

    In my script, I want to open and read a configuration file that has options for the script. The problem is that the File object sometimes thinks the file is empty (length property is 0), and other times it is able to read the file without any problems. I can observe this just by running the script several times in a row.

    Are you opening the file with shared read-only? also, are you closing your handle to the file when done, or otherwise encapsulating the file access into a separate method/function, so the variable falls out of scope?

    When I create the File object, the filename that will get passed to it is something along the lines of this: D:\BBS\sbbs\mods\../xtrn/DigDist\DDLoginMatrixThemes/kd-snake/DDMatrixThe me.cfg

    Is there a known bug related to what I'm describing? Might I simply be passing too long of a path to the File object?

    I couldn't answer this, I can only suggest to be certain you are safely accessing the file with shared read. I can't offer more help than this without knowing more about how your configuration structure is read.

    --
    Michael J. Ryan - http://tracker1.info/

    ... FRA #255: A wife is a luxury ... a smart accountant is a necessity.

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com
  • From Nightfox@VERT/DIGDIST to Tracker1 on Sat Jul 4 20:13:00 2009
    Re: Re: File object randomly thinks file is empty
    By: Tracker1 to Nightfox on Sat Jul 04 2009 14:56:30

    Are you opening the file with shared read-only? also, are you closing yo handle to the file when done, or otherwise encapsulating the file access a separate method/function, so the variable falls out of scope?

    I've solved the problem.. Previous versions of the script had emptied out some of my configuration files because I left out the read mode from File.open().

    Nightfox


    ---
    þ Synchronet þ Digital Distortion BBS