Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found