Skip to content

Commit 61052d9

Browse files
authored
Merge pull request #86 from webonix/FC-3157
FC-3157 - added ability to return file attibutes in ioGetDirectoryListing()
2 parents 0927e55 + bdc00a8 commit 61052d9

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

packages/cdn/local.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,18 @@
276276
<cffunction name="ioGetDirectoryListing" returntype="query" access="public" output="false" hint="Returns a query of the directory containing a 'file' column only. This filename will be equivilent to what is passed into other CDN functions.">
277277
<cfargument name="config" type="struct" required="true" />
278278
<cfargument name="dir" type="string" required="true" />
279+
<cfargument name="listinfo" type="string" required="false" default="name" hint="name or all" />
279280

280281
<cfset var qDir = "" />
281282

282-
<cfdirectory action="list" directory="#getFullPath(config=arguments.config,file=arguments.dir)#" recurse="true" type="file" listinfo="name" name="qDir" />
283+
<cfdirectory action="list" directory="#getFullPath(config=arguments.config,file=arguments.dir)#" recurse="true" type="file" listinfo="#arguments.listinfo#" name="qDir" sort="name" />
283284

284285
<cfquery dbtype="query" name="qDir">
285-
SELECT '#arguments.dir#/' + name AS file
286+
SELECT '#arguments.dir#/' + name AS file, *
286287
FROM qDir
287288
WHERE not name like '%/.%'
288-
ORDER BY name
289289
</cfquery>
290-
290+
291291
<cfreturn qDir />
292292
</cffunction>
293293

packages/cdn/s3.cfc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@
978978
<cffunction name="ioGetDirectoryListing" returntype="query" access="public" output="false" hint="Returns a query of the directory containing a 'file' column only. This filename will be equivilent to what is passed into other CDN functions.">
979979
<cfargument name="config" type="struct" required="true" />
980980
<cfargument name="dir" type="string" required="true" />
981+
<cfargument name="listinfo" type="string" required="false" default="name" hint="name or all" />
981982

982983
<cfset var qDir = "" />
983984
<cfset var s3path = "s3://#arguments.config.accessKeyId#:#arguments.config.awsSecretKey#@#arguments.config.bucket##lcase(arguments.config.pathPrefix)##lcase(arguments.dir)#" />
@@ -986,13 +987,14 @@
986987
<cfreturn querynew("file") />
987988
</cfif>
988989

989-
<cfdirectory action="list" directory="#s3path#" recurse="true" listinfo="name" name="qDir" />
990+
<cfdirectory action="list" directory="#s3path#" recurse="true" listinfo="#arguments.listinfo#" name="qDir" sort="name" />
990991

991-
<cfquery dbtype="query" name="qDir">
992-
SELECT '/' + name AS file
993-
FROM qDir
994-
ORDER BY name
995-
</cfquery>
992+
<cfif arguments.listinfo EQ "name">
993+
<cfset QueryAddColumn( qDir, "file")>
994+
<cfloop query="qDir">
995+
<cfset querysetcell(qDir,"file","/" & qDir.name, qDir.CurrentRow) />
996+
</cfloop>
997+
</cfif>
996998

997999
<cfreturn qDir />
9981000
</cffunction>

packages/lib/cdn.cfc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,13 @@
784784
<cffunction name="ioGetDirectoryListing" returntype="query" access="public" output="false" hint="Lists the files the specfied directory.">
785785
<cfargument name="location" type="string" required="true" />
786786
<cfargument name="dir" type="string" required="false" default="" />
787+
<cfargument name="listinfo" type="string" required="false" default="name" hint="name or all" />
787788

788789
<cfset var config = this.locations[arguments.location] />
789790

790791
<cfset arguments.dir = normalizePath(arguments.dir) />
791792

792-
<cfreturn this.cdns[config.cdn].ioGetDirectoryListing(config=config,dir=arguments.dir) />
793+
<cfreturn this.cdns[config.cdn].ioGetDirectoryListing(config=config,dir=arguments.dir, listinfo=arguments.listinfo) />
793794
</cffunction>
794795

795796
</cfcomponent>

0 commit comments

Comments
 (0)