<div dir="ltr">Thanks. that should be better now.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 8:17 AM, Raimund Steger <span dir="ltr"><<a href="mailto:rs@mytum.de" target="_blank">rs@mytum.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
there is still a problem. d_name gets cut off, hence stat won't find the file.<br>
<br>
I believe it's this:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[...]<span class=""><br>
            p = (struct dirent *) malloc (sizeof (struct dirent));<br>
            memcpy (p, dent, sizeof (struct dirent));<br>
</span></blockquote>
<br>
According to [1], d_name is indeed variable size though might be defined to size 1 in headers, so copying sizeof(struct dirent) with memcpy will likely not work.<br>
<br>
It seems most platforms have a (non-standard) d_reclen field, but the portable way would probably be to add strlen(d_name) before any copying is done.<br>
<br>
-Raimund<br>
<br>
<br>
<br>
[1] <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html" target="_blank">http://pubs.opengroup.org/<u></u>onlinepubs/9699919799/<u></u>basedefs/dirent.h.html</a><span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
-- <br>
Worringer Str 31 Duesseldorf 40211 DE  home: <<a href="mailto:rs@mytum.de" target="_blank">rs@mytum.de</a>><br>
<a href="tel:%2B49-179-2981632" value="+491792981632" target="_blank">+49-179-2981632</a> icq 16845346           work: <<a href="mailto:rs@interface-ag.de" target="_blank">rs@interface-ag.de</a>><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Akira TAGOH</div>
</div>