CFLib.org – Common Function Library Project

getFileSpace()

Last updated October 12, 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>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson