CFLib.org – Common Function Library Project

FileInfo(fileName)

Last updated October 15, 2002

Version: 1 | Requires: ColdFusion MX | Library: CFMLLib

 
Rated 0 time(s). Average Rating: 0

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

Return Values:
Returns a query.

Example:

view plain print about
<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:

view plain print about
<!---
 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

Tayo Akinmade Tayo Akinmade added
arrayTrim
10 day(s) ago

Will Belden Will Belden added
longTime
15 day(s) ago

James Sleeman James Sleeman added
quickSort
25 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
28 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson