digitalmars.D - Why doesn't listdir() work?
- kinghajj <kinghajj_member pathlink.com> Jul 12 2004
- Ben Hinkle <bhinkle4 juno.com> Jul 12 2004
- "Vathix" <vathixSpamFix dprogramming.com> Jul 12 2004
- kinghajj <kinghajj_member pathlink.com> Jul 12 2004
- "Vathix" <vathixSpamFix dprogramming.com> Jul 13 2004
- kinghajj <kinghajj_member pathlink.com> Jul 12 2004
- Ben Hinkle <bhinkle4 juno.com> Jul 12 2004
- "Matthew" <admin stlsoft.dot.dot.dot.dot.org> Jul 12 2004
- "Carlos Santander B." <carlos8294 msn.com> Jul 12 2004
- "Matthew" <admin stlsoft.dot.dot.dot.dot.org> Jul 12 2004
- kinghajj <kinghajj_member pathlink.com> Jul 12 2004
- "Matthew" <admin stlsoft.dot.dot.dot.dot.org> Jul 12 2004
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= <juanjuxNO SPAMyahoo.es> Jul 12 2004
- "Matthew Wilson" <dmd synesis.com.au> Jul 13 2004
My code:
import std.file;
int main(char[][] args)
{
if(args.length != 2)
{
return 0;
}
if(exists(args[1]) && isdir(args[1]))
{
char[][] contents = listdir(args[1]);
printf("Directory listing for %.*s:\n\n", args[1]);
for(int i = 0;i < contents.length;i++)
{
printf("%.*s", contents);
}
}
return 0;
}
Why won't listdir() work?
I'm using DMD 0.95 on Linux (Fedora Core 2).
Jul 12 2004
kinghajj wrote:My code: import std.file; int main(char[][] args) { if(args.length != 2) { return 0; } if(exists(args[1]) && isdir(args[1])) { char[][] contents = listdir(args[1]); printf("Directory listing for %.*s:\n\n", args[1]); for(int i = 0;i < contents.length;i++) { printf("%.*s", contents); } } return 0; } Why won't listdir() work? I'm using DMD 0.95 on Linux (Fedora Core 2).
This might have something to do with it. From std/file.d: char[][] listdir(char[] pathname) { assert(0); // BUG: not implemented return null; }
Jul 12 2004
"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:ccv4m4$cm5$1 digitaldaemon.com...kinghajj wrote:My code: import std.file; int main(char[][] args) { if(args.length != 2) { return 0; } if(exists(args[1]) && isdir(args[1])) { char[][] contents = listdir(args[1]); printf("Directory listing for %.*s:\n\n", args[1]); for(int i = 0;i < contents.length;i++) { printf("%.*s", contents); } } return 0; } Why won't listdir() work? I'm using DMD 0.95 on Linux (Fedora Core 2).
This might have something to do with it. From std/file.d: char[][] listdir(char[] pathname) { assert(0); // BUG: not implemented return null; }
I implemented it quite awhile ago and it was never used: digitalmars.D/796
Jul 12 2004
In article <ccv5go$e9i$1 digitaldaemon.com>, Vathix says...I implemented it quite awhile ago and it was never used: digitalmars.D/796
I can't decode the base64... the quick base64 encoder/decoder (written in D :) that I made says that the string is invalid (I removed all of the newlines). Can you re-post the code without using the base64 encoding?
Jul 12 2004
"kinghajj" <kinghajj_member pathlink.com> wrote in message news:ccvflu$te5$1 digitaldaemon.com...In article <ccv5go$e9i$1 digitaldaemon.com>, Vathix says...I implemented it quite awhile ago and it was never used: digitalmars.D/796
I can't decode the base64... the quick base64 encoder/decoder (written in
that I made says that the string is invalid (I removed all of the
Can you re-post the code without using the base64 encoding?
I don't think it's base64, you might need to use uudecode on it. Here's the file www.dprogramming.com/listdir.d . I updated it to contain the changes made to the origional listdir() for Windows, and added a finally block for the cleanup code in case an exception is thrown during the callback. The code is donated to the public domain.
Jul 13 2004
In article <ccv4m4$cm5$1 digitaldaemon.com>, Ben Hinkle says...This might have something to do with it. From std/file.d: char[][] listdir(char[] pathname) { assert(0); // BUG: not implemented return null; }
No, becuase on mine the function is this: char[][] listdir(char[] pathname) { char[][] result; char[] c; HANDLE h; c = std.path.join(pathname, "*.*"); if (useWfuncs) { WIN32_FIND_DATAW fileinfo; h = FindFirstFileW(std.utf.toUTF16z(c), &fileinfo); if (h != INVALID_HANDLE_VALUE) { do { int i; int clength; // Skip "." and ".." if (std.string.wcscmp(fileinfo.cFileName, ".") == 0 || std.string.wcscmp(fileinfo.cFileName, "..") == 0) continue; i = result.length; result.length = i + 1; clength = std.string.wcslen(fileinfo.cFileName); result[i] = std.utf.toUTF8(fileinfo.cFileName[0 .. clength]); } while (FindNextFileW(h,&fileinfo) != FALSE); FindClose(h); } } else { WIN32_FIND_DATA fileinfo; h = FindFirstFileA(toMBSz(c), &fileinfo); if (h != INVALID_HANDLE_VALUE) { do { int i; int clength; wchar[] wbuf; int n; // Skip "." and ".." if (std.string.strcmp(fileinfo.cFileName, ".") == 0 || std.string.strcmp(fileinfo.cFileName, "..") == 0) continue; i = result.length; result.length = i + 1; clength = std.string.strlen(fileinfo.cFileName); //result[i] = fileinfo.cFileName[0 .. clength].dup; // Convert cFileName[] to unicode wbuf.length = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,null,0); n = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,cast(wchar*)wbuf,wbuf.length); assert(n == wbuf.length); result[i] = std.utf.toUTF8(wbuf); } while (FindNextFileA(h,&fileinfo) != FALSE); FindClose(h); } } return result; } Maybe it's Windows-only?
Jul 12 2004
Maybe it's Windows-only?
yup - the OP said they were on Linux. The Windows version is fine.
Jul 12 2004
Why not use std.recls? "kinghajj" <kinghajj_member pathlink.com> wrote in message news:ccv3l5$bk3$1 digitaldaemon.com...My code: import std.file; int main(char[][] args) { if(args.length != 2) { return 0; } if(exists(args[1]) && isdir(args[1])) { char[][] contents = listdir(args[1]); printf("Directory listing for %.*s:\n\n", args[1]); for(int i = 0;i < contents.length;i++) { printf("%.*s", contents); } } return 0; } Why won't listdir() work? I'm using DMD 0.95 on Linux (Fedora Core 2).
Jul 12 2004
"Matthew" <admin stlsoft.dot.dot.dot.dot.org> escribió en el mensaje news:ccvb87$mht$1 digitaldaemon.com... | Why not use std.recls? | I think listdir should work anyway, don't you? ----------------------- Carlos Santander Bernal
Jul 12 2004
"Carlos Santander B." <carlos8294 msn.com> wrote in message news:ccvc8d$o78$1 digitaldaemon.com..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> escribió en el mensaje news:ccvb87$mht$1 digitaldaemon.com... | Why not use std.recls? | I think listdir should work anyway, don't you?
Of course. I was just being practical, to get him working right now. :)
Jul 12 2004
In article <ccvb87$mht$1 digitaldaemon.com>, Matthew says...Why not use std.recls?
I thought that that wasn't in the library yet. I'll check it out :)
Jul 12 2004
It has been for a long time. For a while there was an issue with linking (as it'd been left out of the build for phobos), but that was fixed several versions ago. "kinghajj" <kinghajj_member pathlink.com> wrote in message news:ccvesp$s5l$1 digitaldaemon.com...In article <ccvb87$mht$1 digitaldaemon.com>, Matthew says...Why not use std.recls?
I thought that that wasn't in the library yet. I'll check it out :)
Jul 12 2004
Matthew wrote:It has been for a long time. For a while there was an issue with linking (as it'd been left out of the build for phobos), but that was fixed several versions ago.
Do you accept suggestions? I've just looked at recls and I think is great but it _really_ need a new name (fssearch maybe?) because the current one doesn't says nothing ;)
Jul 12 2004
"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cd00s0$1q6d$1 digitaldaemon.com...Matthew wrote:It has been for a long time. For a while there was an issue with linking (as it'd been left out of the build for phobos), but that was fixed several versions ago.
Do you accept suggestions?
I do. I don't always respond to them, though.I've just looked at recls and I think is great but it _really_ need a new name (fssearch maybe?) because the current one doesn't says nothing ;)
recls comes from RECursive LS (as in the UNIX command). I also like it because it allows the pronunciation "reckless", which is kinda ironic. ;) It's now way too established to change the name - it's mapped to several other languages/technologies (including C++, COM, C#/.NET, Java, Ruby and STL) - but thanks for taking the trouble to think about it anyway. Cheers Matthew
Jul 13 2004









"Vathix" <vathixSpamFix dprogramming.com> 