in reply to Need Advice on Folder/Drive locking

Not sure if windows supports sparse files but I did the same task in unix by making a *SPARSE* lock file that was the same size as the file I was copying and used that in my size calculations.

sysopen( $fh, $lock_filename, O_RDWR | O_CREAT ); seek($fh, $filesize,0); truncate($fh,$filesize);

Then a stat call gives us the sparse size while the filesystem hasn't grown at all. To get a rough idea of free space you can tally the free space the FS reports minus the sum of the size of all your sparse lock files.

Update: Code typos fixed

Replies are listed 'Best First'.
Re^2: Need Advice on Folder/Drive locking
by Marshall (Canon) on Feb 05, 2010 at 08:49 UTC
    interesting idea. Yes, Windows NTFS does support sparse files. to make one...see below.

    One link http://msdn.microsoft.com/en-us/library/aa365564(VS.85).aspx
    Google "windows sparse file" for others including "FSUTIL Sparse" command line manager on Win XP.

    #!/usr/bin/perl -w use strict; open(FILE, ">", "sparse") || die "unable to open for write\n"; print FILE "some stuff"; seek(FILE,1000000,0); print FILE "more stuff"; close FILE;