www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Can't fix segmentation fault

reply KUV <KUV_member pathlink.com> writes:
Here is a code below that generate directory tree. When I am trying to run it on
big folders, it causes 'segmentation fault' error.
May be anyone knows some possible reasons for this?



private import std.file;

struct FileDesc {
char[] path;
ulong size;
}

public FileDesc[] list() {
FileDesc[] res = null;
FileDesc file;

void scandir(char[] path) {
foreach(char[] name; listdir(basepath ~ path)) {
file.path = path ~ name;
if (isdir(basepath ~ file.path)) {
file.size = 0;
res ~= file;
scandir(file.path ~ '/');
} else {
file.size = getSize(basepath ~ file.path);
res ~= file;
}
}
}

scandir("");
return res;
}
Jan 12 2006
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
KUV wrote:

 Here is a code below that generate directory tree. When I am trying to run it
on
 big folders, it causes 'segmentation fault' error.
 May be anyone knows some possible reasons for this?
Q: What did the debugger say ? (compile with -g, run with gdb) --anders
Jan 12 2006