in reply to Re: Re: Disk Space used by a folder (and sub folders)
in thread Disk Space used by a folder (and sub folders)

hm, doesn't stat function exist on win32? :))
#!/usr/bin/perl -w use strict; use File::Find; print "Total: ", GetFolderSize( defined $ARGV[0]?$ARGV[0]:'.'), $/; sub GetFolderSize { local $% = 0; find( { wanted => sub { local ($-,$=) = (-s,(stat)[11]); $%+=(int($-/$=)+($-%$=?1:0))*$= }},shift);$% }

--
AltBlue.

Replies are listed 'Best First'.
Re: Re: Disk Space used by a folder (and sub folders)
by $code or die (Deacon) on Jan 27, 2001 at 07:03 UTC
    Not sure, but I got an illegal divide by zero error when running your example.

    I'll play around with your code and see if I can get it to work.

    $code or die
    Using perl at
    The Spiders Web
      error on getting (stat)[11] could get you a division by zero. i don't have any win32 machines to test this snippet on them, so good luck :)
      on linux and solaris it works ok, outputs exactly the same as du -b. :)
      (one quick solution w'd ofc be an 'and' between those two lines in my subroutine)

      --
      AltBlue.

        I was going to check this when it first came up but couldn't. (stat)[11] under Win32 is the empty string.

                - tye (but my friends call me "Tye")