www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - File append limit?

reply Joshua Niehus <jm.niehus gmail.com> writes:
--0022158c0589244b7104a9c3d984
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I am running a script that creates a file which lists all the folders in a
directory:

    foreach (string name; dirEntries("/Users/josh/", SpanMode.shallow)) {
        append("/Users/dirList.txt", name ~ "\n");
    }

But it seems to stop appending after 255 lines (this particular folder has
350 folders in all).
When trying to read the created file:

   auto f = File("/Users/dirList.txt", "r");
   foreach (string line; lines(f)) {
       writeln(line);
   }
   f.close();

It writes out the lines, but after the last one I get "Bus error: 10"

Any thoughts on what im missing or doing wrong?

I am currently using D 2.054 on Mac OSX Lion
The script was working with D 2.053 on Mac OSX Snow Leopard

Thanks,
Josh

--0022158c0589244b7104a9c3d984
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,<div><br></div><div>I am running a script that creates a file which l=
ists all the folders in a directory:</div><div><div>=A0 =A0=A0</div><div>=
=A0 =A0 foreach (string name; dirEntries(&quot;/Users/josh/&quot;, SpanMode=
.shallow)) {</div>
<div>=A0 =A0 =A0 =A0 append(&quot;/Users/dirList.txt&quot;, name ~ &quot;\n=
&quot;);</div><div>=A0 =A0 }</div></div><div><br></div><div>But it seems to=
 stop appending after 255 lines (this particular folder has 350 folders in =
all). =A0</div>
<div>When trying to read the created file:</div><div><br></div><div><div>=
=A0 =A0auto f =3D File(&quot;/Users/dirList.txt&quot;, &quot;r&quot;);</div=
<div>=A0 =A0foreach (string line; lines(f)) {</div><div>=A0 =A0 =A0 =A0wri=

<div>=A0 =A0}</div><div>=A0 =A0f.close();</div><div><br></div><div>It write= s out the lines, but after the last one I get &quot;Bus error: 10&quot;</di= v><div><br></div><div>Any thoughts on what im missing or doing wrong?=A0</d= iv><div> =A0 =A0</div></div><div>I am currently using D 2.054 on Mac OSX Lion</div><= div>The script was working with D 2.053 on Mac OSX Snow Leopard</div><div><= br></div><div>Thanks,</div><div>Josh</div> --0022158c0589244b7104a9c3d984--
Aug 05 2011
next sibling parent Kagamin <spam here.lot> writes:
Joshua Niehus Wrote:

 Hello,
 
 I am running a script that creates a file which lists all the folders in a
 directory:
 
     foreach (string name; dirEntries("/Users/josh/", SpanMode.shallow)) {
         append("/Users/dirList.txt", name ~ "\n");
     }
 
 But it seems to stop appending after 255 lines (this particular folder has
 350 folders in all).

What if foreach(i;0..512) { append("/Users/dirList.txt", text("line ",i,'\n')); }
Aug 05 2011
prev sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 05.08.2011 19:35, Joshua Niehus wrote:
 Hello,

 I am running a script that creates a file which lists all the folders 
 in a directory:
     foreach (string name; dirEntries("/Users/josh/", SpanMode.shallow)) {
         append("/Users/dirList.txt", name ~ "\n");
     }

 But it seems to stop appending after 255 lines (this particular folder 
 has 350 folders in all).
 When trying to read the created file:

    auto f = File("/Users/dirList.txt", "r");
    foreach (string line; lines(f)) {
        writeln(line);
    }
    f.close();

 It writes out the lines, but after the last one I get "Bus error: 10"

 Any thoughts on what im missing or doing wrong?
 I am currently using D 2.054 on Mac OSX Lion
 The script was working with D 2.053 on Mac OSX Snow Leopard

 Thanks,
 Josh

I'd suspect that it's a manifestation of a recently dsicovered (and fixed) bug with OSX Lion, more info here: https://github.com/D-Programming-Language/druntime/pull/42 At any rate it's going to be into the next release, other then waiting for it you can manually build latest dmd/druntime from github. -- Dmitry Olshansky
Aug 05 2011