digitalmars.D - Why doesn't listdir() work?
- kinghajj (21/21) Jul 12 2004 My code:
- Ben Hinkle (7/32) Jul 12 2004 This might have something to do with it. From std/file.d:
- Vathix (4/36) Jul 12 2004 I implemented it quite awhile ago and it was never used:
- kinghajj (4/6) Jul 12 2004 I can't decode the base64... the quick base64 encoder/decoder (written i...
- Vathix (9/17) Jul 13 2004 D :)
- kinghajj (61/67) Jul 12 2004 No, becuase on mine the function is this:
- Ben Hinkle (1/2) Jul 12 2004 yup - the OP said they were on Linux. The Windows version is fine.
- Matthew (3/24) Jul 12 2004 Why not use std.recls?
-
Carlos Santander B.
(7/7)
Jul 12 2004
"Matthew"
escribió en el mensaje - Matthew (3/8) Jul 12 2004 Of course. I was just being practical, to get him working right now. :)
- kinghajj (2/3) Jul 12 2004 I thought that that wasn't in the library yet. I'll check it out :)
- Matthew (4/9) Jul 12 2004 It has been for a long time. For a while there was an issue with linking...
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= (4/7) Jul 12 2004 Do you accept suggestions? I've just looked at recls and I think is grea...
- Matthew Wilson (10/18) Jul 13 2004 I do. I don't always respond to them, though.
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:I implemented it quite awhile ago and it was never used: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/796My 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
In article <ccv5go$e9i$1 digitaldaemon.com>, Vathix says...I implemented it quite awhile ago and it was never used: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/796I 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...D :)I implemented it quite awhile ago and it was never used: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/796I can't decode the base64... the quick base64 encoder/decoder (written inthat I made says that the string is invalid (I removed all of thenewlines).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:I do. I don't always respond to them, though.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 ;)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 STL) - but thanks for taking the trouble to think about it anyway. Cheers Matthew
Jul 13 2004