<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><br><div>OK, firstly ,where's the new documentation of new V8 js module ?</div><div><br></div><div>Secondly, I think,  loop read small piece of  file will cause  too much I/O request . SO , i usually do read in following way. </div><div>open the file ----> get file size --> read the whole file ( OS will charge the "one time " read size).</div><div><br></div><div>and in real-life , real-project , there's not so many big files.  So, just  open the file ,and  read all.    in 99.99% situation , it's safe.</div><div><br></div><div>in some situation , you cann't open the "<span style="font-family: Helvetica, "Microsoft Yahei", verdana;">incomplete</span><span style="font-family: Helvetica, "Microsoft Yahei", verdana;"> file"  , you even cann't "see" them. </span><span style="font-family: Helvetica, "Microsoft Yahei", verdana;">There's too much detail when we talk about file read ,we can discuss file-system in rest of our life.</span></div><div><span style="font-family: Helvetica, "Microsoft Yahei", verdana;"> For </span>Faruq ,<span style="font-family: Helvetica, "Microsoft Yahei", verdana;"> i think  just read whole file is  ok .  if you warry about "</span><span style="font-family: Helvetica, "Microsoft Yahei", verdana;">incomplete file" ,just wait 1 second ,and  read the file size again. it's  may casuse delay ,but useful if you have lots of files to read .</span></div><div><span style="font-family: Helvetica, "Microsoft Yahei", verdana;"><br></span></div><div><font face="Helvetica, Microsoft Yahei, verdana">In my opinion, </font><span style="font-family: Helvetica, "Microsoft Yahei", verdana;">when linux  do file read ,it read 1 block one time . </span><font face="Helvetica, Microsoft Yahei, verdana">A block is a sequence of bit or Bytes with a fixed length ie 512 bytes, 4kB, 8kB, 16kB, 32kB etc.  So , please not use strange number as your read size. it's not a good idea.  And  ......I really hate "while (.....)"  code ,it's really really bad.</font></div><div><font face="Helvetica, Microsoft Yahei, verdana"><br></font></div><div><font face="Helvetica, Microsoft Yahei, verdana">Raymond</font></div><br><div style="position:relative;zoom:1"></div><div id="divNeteaseMailCard"></div><br>At 2017-06-24 04:00:36, "Anthony Minessale" <anthony.minessale@gmail.com> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr">That wiki documentation is from the old spidermonkey js module not the new v8 one.<div><br></div><div>I believe that putting a very large number will not cause any problems as the data read cannot exceed the total bytes in the file so it should not be a problem.</div><div>You can always do an append loop.  Its usually a good practice to have a precise max size to read because what if the file was accidentally 2gb.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 23, 2017 at 3:36 AM, Raymond <span dir="ltr"><<a href="mailto:xxxman2008@126.com" target="_blank">xxxman2008@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi ,</div><div><br></div><div>   This will help you  . <a href="https://wiki.freeswitch.org/wiki/File" target="_blank">https://wiki.freeswitch.<wbr></wbr>org/wiki/File</a><span class="HOEnZb"><font color="#888888"> </font></span></div><span class="HOEnZb"><font color="#888888"><div>   </div><div style="zoom:1"></div><div id="m_-1722616414546404880divNeteaseMailCard"></div><div>Raymond</div></font></span><div><div class="h5"><div><br></div>At 2017-06-22 21:49:33, "Faruq Ahmad" <<a href="mailto:afarooqa@gmail.com" target="_blank">afarooqa@gmail.com</a>> wrote:<br> <blockquote id="m_-1722616414546404880isReplyContent" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><div dir="ltr">Hi,<br><br>I have a FS dialplan that fetches callflow from a JSON file. File is read using <br><br>var JsonFd = new FileIO(JsonPath, 'r');<br><div>JsonFd.read(2048);</div><div><div>result = JsonFd.data();</div></div><div><div>var menu = JSON.parse(result),</div></div><div><br>Is there anyway I can read the whole file in one attempt, i.e. when a smaller size was given to the .read() function it wouldn't read the complete file. I have increased the value of size for read function however my concern is in the long run file size might increase and parse would get an incomplete JSON. <br><br>Is there anyway I can get filesize from FileIO object or detect EOF from the read buffer to make sure the whole file is loaded?<br>Also if I increase the size for read fucntion buffer way over the estimated filesizes, is there any guarantee that no garbage values will be read from the disk after the EOF?</div></div>
</blockquote></div></div></div><br><br><span title="neteasefooter"><p> </p></span><br>______________________________<wbr></wbr>______________________________<wbr></wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.<wbr></wbr>freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.<wbr></wbr>org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.<wbr></wbr>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/<wbr></wbr>mailman/listinfo/freeswitch-<wbr></wbr>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.<wbr></wbr>freeswitch.org/mailman/<wbr></wbr>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬<div><br><div>☞ <a href="http://freeswitch.org/" target="_blank">http://freeswitch.org/</a>  ☞ <a href="http://cluecon.com/" target="_blank">http://cluecon.com/</a>  ☞ <a href="http://twitter.com/FreeSWITCH" target="_blank">http://twitter.com/FreeSWITCH</a></div><div><div>☞ <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch ☞ <u><a href="http://freeswitch.org/g+" target="_blank">http://freeswitch.org/g+</a></u><br><br></div><div>ClueCon Weekly Development Call <br></div><div>☎ <a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a>  ☎ +19193869900 </div><div><br></div></div></div><div><a href="https://www.youtube.com/watch?v=9XXgW34t40s" style="color:rgb(17,85,204);font-size:12.8000001907349px" target="_blank">https://www.youtube.com/watch?v=9XXgW34t40s</a></div><div><a href="https://www.youtube.com/watch?v=NLaDpGQuZDA" target="_blank">https://www.youtube.com/watch?v=NLaDpGQuZDA</a><br></div></div></div></div></div></div></div>
</div>
</blockquote></div><br><br><span title="neteasefooter"><p> </p></span>