The biggest problem with system calls is that you restrict yourself to a single platform.Do you mean 'system calls', or a call to system? Different beasts. Very different beasts.
Anyway, to get information like you want, you will have to query the OS. That, in general, is done differently on different OSses. For a few things, Perl hides this difference from the user, but internally it will do different things (different system calls). There's no Perl primitive for querying disks. (Well, you probably don't want to know how much space is left on a disk. You want to know how much space is left on a filesystem - there can be more than one filesystem on a disk, and a filesystem often lies over several disks, especially at very large companies. Think RAID. Think volumes.) There's no Perl primitive for querying filesystems. There's no POSIX function for it.
I think your best option is to use df, which, IIRC, has been ported to Windows as well. (Almost any standard Unix tool is available under Windows). That will give you a consistant interface.
I also don't want to use very many modules, because often our customers do not allow extra modules to be loaded on their systems (think very large companies with very tight security and concern for software support -- and perhaps a prohibitively inefficient IT group).I find that a non-argument. What do they say. "We are a very large company. We hire you to write software, but your software may consist of only one file"? What do they do if they hire someone to write a Java application? Everything has to be in a single file? There's hardly any difference between a Perl program and a Perl module - except that the latter doesn't require execution bits.
My question, then, is How do I calculate total blocks on a volume? I figure that I can use File::Find and lstat to get the blocks used, subtract that value from total blocks, and get blocks available.Well, that would be wrong, because that wouldn't take links into account, even resulting into thinking that you have a negative amount of blocks available. Not to mention that this solution could be horribly slow - you'd have to do work (and what a work it is, considering how expensive a subroutine call in Perl is) for every file.
Abigail
In reply to Re: Perl-only Disk Size/Usage
by Abigail-II
in thread Perl-only Disk Size/Usage
by ccarden
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |