commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [io] Submission: Commons IO GetFreeSpace]
Date Thu, 06 Jan 2005 23:35:45 GMT
Fair enough... Here's two use cases I myself had for this...

(1) For a file manager application I wrote, one of the required 
functions was displaying free space on a volume

(2) For another application we wanted to allow user uploads to a volume 
   set aside specifically for the uploads, so we had to know before 
trying to write out the file whether there was enough space, and be able 
to display for the user how much was available for uploads

I also did a few minutes of Googling... the common use case that I found 
a number of times is copying or creating files on a drive, the developer 
wants to know before they start that there will be enough room to 
complete the operation, rather than handling exceptions.  This is 
especially useful if you are going to be copying a number of files for 
instance and need it to be an all-or-nothing proposition.  The 
alternative is copy until a failure occurs, then clean up whatever did 
get copied, kind of an ugly approach.  With my method you can determine 
before hand if there's enough space.

Is that what you were looking for?

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


Stephen Colebourne wrote:
> I was looking for use cases before deciding whether to +1 or -1 it into 
> [io].
> 
> Stephen
> 
> ----- Original Message ----- From: "Frank W. Zammetti" 
> <fzlists@omnytex.com>
> 
>> Forgive me, it was before the holidays, so my memory is foggy... was 
>> there any resolution on whether this would be added to Commons IO or 
>> not?  Did I possibly miss it being added?  Or, do I need to roll it 
>> into a FileSystemUtils class as Stephen mentions?  I can take care of 
>> that probably tonight if that's all that's holding it up (but I don't 
>> know if it was being accepted in the first place)
>>
>> -- 
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>>
>> ---------------------------- Original Message 
>> ----------------------------  Subject: Re: [io] Submission: Commons IO 
>> GetFreeSpace From: "Stephen Colebourne" <scolebourne@btopenworld.com> 
>> Date: Thu, December 23, 2004 12:49 pm To: "Jakarta Commons Developers 
>> List" <commons-dev@jakarta.apache.org> 
>> -------------------------------------------------------------------------- 
>>
>> Prefixing by [io] would help...... This is quite a clever solution to 
>> this problem, especially not using any native code. I am of mixed 
>> views as to whether to add it to [io] however. My question would be as 
>> to why you would need to know this information. What is a real use 
>> case (as I've never faced one). If we did add it , it would have to be 
>> a FileSystemUtils. Stephen ----- Original Message ----- From: 
>> <fzlists@omnytex.com>
>>
>> >> Please download package at
>> >> http://www.omnytex.com/commons-io-getfreespace.zip
>> >>
>> >> I submit this here for consideration of being added to Commons IO.  If
>>
>> this should be directed elsewhere, I would appreciate that information.
>> Thanks for your time!
>>
>> >>
>> >> Synopsis
>> >> --------
>> >> A common question I've seen asked (and been asked myself numerous 
>> >> times)
>>
>> is how to get the free space on a volume in a pure-Java way. At the
>> present time, as far as I know, nothing like this exists
>>
>> >> in the SDKs.  So, I set out to write a class that could do it
>> >> for any platform (almost) without using JNI.  It's still not really a
>>
>> pure-Java solution since it uses System.exec to shell out to an
>> OS-specific utility (dir for Windows, df for *nix) to get the
>>
>> >> information.
>> >>
>> >> I have tested this on Windows XP, Windows 2000, Windows NT,
>> >> RedHat Linux and Mandrake Linux.  I believe it will work on
>> >> virtually any Windows or *nix platform, although the more
>> >> verification of this I can get, the better!
>> >>
>> >> I have purposely left out support for some platforms like AS/400 and
>>
>> OS/390 because I frankly don't know anything about them and
>>
>> >> don't have access to them to test.  Perhaps down down...
>> >>
>> >> To use it, simply instantiate a GetFreeSpace object and call the
>>
>> GetFreeSpace() method, passing it a path.  This will be a drive
>>
>> >> letter, including the colon, on Windows, or a mounted filesystem on
>>
>> *nix.  An IOEXception is thrown if anything goes wrong, with
>>
>> >> an at least somewhat descriptive message about what may have
>> >> gone wrong.  Generally-speaking, if used as specified, it should "just
>>
>> work".  (Does it make more sense to make this a static method of some
>> other Commons object?  Anyone?)
>>
>> >>
>> >>
>>
>>
>>
>> --------------------------------------------------------------------------------

>>
>>
>>
>>
>> >> 
>> ---------------------------------------------------------------------  
>> >> To
>>
>> unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For
>> additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For
>> additional commands, e-mail: commons-dev-help@jakarta.apa
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message