digitalmars.D - Can't fix segmentation fault
- KUV (28/28) Jan 12 2006 Here is a code below that generate directory tree. When I am trying to r...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/7) Jan 12 2006 Q: What did the debugger say ?
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
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








=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se>