• File object randomly thinks file is empty

    From Nightfox@VERT/DIGDIST to All on Fri Jul 3 20:55:30 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 23:39:40 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 12:24:24 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 14:56:30 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 Sun Jul 5 00:13:07 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ã