News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Why this part of code does not work?

Started by stanks, January 24, 2012, 10:51:10 AM

Previous topic - Next topic

stanks


static
...
  _Pgs: dword [4096];
  _Dir: str.strvar (256);
  _Dir2: str.strvar (256);
  _uk: uns32 := 0;
  _homeDir: string := "/home";

...
...
  mov (mem.alloc (4096), _Pgs);
  foreach filesys.dirIn (_homeDir) do
    push (eax);
    str.cat3 (_homeDir,  "/", _Dir);
    pop (eax);
    str.cat3 (_Dir, (type string eax), _Dir2);
    xor (ebx, ebx);
    foreach filesys.fileIn (_Dir2) do
      // At this point, EAX points at a filename of a file
      // found in the "dirToSearch" directory.
      // if eax is not NULL then show/take filename
      mov (eax, _Pgs[ebx*4]);
      inc (ebx);
    endfor;
    add (ebx, _uk);
  endfor;
  stdout.put (_uk, nl);


thanks

stanks

#1
i have tried only this and it still does not work as it should be


  foreach filesys.dirIn ("/home/stanks") do
    stdout.put ((type string eax), nl);
  endfor;

stanks

anyone?

some dirs are missing. why?
and another problem with this....it returns files too, but reference says that returns only dir names and not file names.

stanks

maybe i am doing something wrong or there is a bug in some functions (filesys.dirIn).
if i use filesys.cd then filesys.dirInCwd i get all dirs in current dir and i don't get any memory allocation (or some other) exception.