CFLib.org – Common Function Library Project

getFileSpace()

Last updated October 11, 2011

author

Sigi

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Gets available and total file space for all volumes on a server.

Return Values:
Returns an array.

Example:

<cfdump var="#getFileSpace()#" />

Parameters:

No arguments.

Full UDF Source:

<!---
 Gets available and total file space for all volumes on a server.
 
 @return Returns an array. 
 @author Sigi (siegfried.heckl@siemens.com) 
 @version 1, October 11, 2011 
--->
<cffunction name="getFileSpace" access="public" output="false" returntype="array" hint="returns disk filespaces of the server">
  <cfset var local = {} />
  <cfset var i = "">

  <cfobject type="java" action="create" class="java.io.File" name="local.objFile" />
  <cfset local.aDrives = local.objFile.listRoots() />
  <cfset local.aResult = [] />

  <cfloop array="#local.aDrives#" index="i">
    <cfset local.strTemp = { drivename = i.getAbsolutePath(),
                             available = i.getFreeSpace(),
                             total     = i.getTotalSpace() } />
    <cfset arrayAppend(local.aResult, local.strTemp) />
  </cfloop>

  <CFRETURN local.aResult />
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson