Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is as much a question as a statement as I don't have access to a network on which to test this properly... Perhaps someone could verify it.

There seems to be one caveat with jsprat's technique. It works brilliantly provided the share is sharing the root of the remote drive, and not some subset of it. However, if the share represents a subdir on the actual remote drive, the information returned by the GetDrive() call represents the entire drive rather than just the shared portion of it. Or at least it appears to in my tests using local shares.

There is an alternative FileSystemObject call, GetFolder()->size(), which will return the correct information, but I think that it is doing a recursive descent accumulating filesizes as it goes, and so is possibly not much quicker than using this technique in Perl.

Anyway, here are the results I got when I shared my perl directory, e:\perl as \\mymachine\perl f:

#! perl -sw use strict; use Win32::OLE; use Benchmark; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $local = $fs->GetFolder('e:/perl'); print 'e:\perl: ', $local->size(), ' used', $/; my $f = $fs->GetFolder('f:/'); #! e:/perl shared as f: print 'f:\ (e:\perl shared as f:): ', $f->size(), ' used', $/; my $d = $fs->GetDrive('f:'); #! e:/perl shared as f: print 'f: (using GetDrive()): ', $d->{TotalSize} - $d->{FreeSpace}, " +used\n"; __DATA__ c:\test>204222 e:\perl: 52488590 used f:\ (e:\perl shared as f:): 52488590 used f: (using GetDrive()): 2614812672 used c:\test>

I was intending to try and benchmark the two methods, but it appears to cache the value after the first call and i couldn't see any simple way of clearing the cache without rebooting, so I'll leave that to Ozzy

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

In reply to Re: Find A Share size in Win2k by BrowserUk
in thread Find A Share size in Win2k by OzzyOsbourne

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2024-07-18 08:52 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.