CFLib.org – Common Function Library Project

FileInfo(fileName)

Last updated October 15, 2002

author

Raymond Camden

Version: 1 | Requires: CF6 | Library: CFMLLib

Description:
Returns information about a file. This includes: attributes, datelastmodified, mode, name, size, and type.

Return Values:
Returns a query.

Example:

<cfscript>
x=fileInfo(expandPath(".") & "\" & listLast(cgi.script_name,"/"));
</cfscript>

<cfdump var="#x#" label="File Info">

Parameters:

Name Description Required
fileName File to inspect. Yes

Full UDF Source:

<!---
 Returns information about a file.
 Updated for CMFX var scope.
 
 @param fileName 	 File to inspect. (Required)
 @return Returns a query. 
 @author Raymond Camden (ray@camdenfamily.com) 
 @version 1, October 15, 2002 
--->
<cffunction name="fileInfo" output="false" returntype="query">
	<cfargument name="fileName" type="string" required="true">

	<cfset var directory = "">
	<cfset var getFile = queryNew("")>
	
	<cfif not fileExists(fileName)>
		<cfthrow message="fileInfo error: #fileName# does not exist.">
	</cfif>
	<cfset directory = getDirectoryFromPath(fileName)>
	<cfdirectory name="getFile" directory="#directory#" filter="#getFileFromPath(fileName)#">
	<cfreturn getFile>
</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