I was a bit bored at home last night and since I'm trying to learn java
I wrote one as a java cfx, it's pretty damn quick, you may find it
useful.

Call it with..

<cfx_recursiveDir dir="c:\aDir" queryname="myNewCFQuery">

It creates a query object in the calling cf template.

---code----

import com.allaire.cfx.*;
import java.io.*;

public class recursiveDir implements CustomTag{
        public void processRequest( Request request, Response response )
throws Exception{
        if (!request.attributeExists("dir") ||
!request.attributeExists("queryname"))
        {
           throw new Exception("Missing attribute 'dir'");
        }       
        String dir = request.getAttribute("dir");
        String queryname = request.getAttribute("queryname");
        String[] columns = { "Type" , "filename"} ;
        Query query = response.addQuery( queryname, columns ) ;
        recurseInDirFrom(dir,query);
        }
        public void recurseInDirFrom(String dirItem, Query query) {
                File file;
                String list[];
                String type;
                file = new File(dirItem);
                if (file.isDirectory()) {
                        list = file.list();
                        for (int i = 0; i < list.length; i++)
                                recurseInDirFrom(dirItem +
File.separatorChar + list[i], query);
                                type = "Directory";
                } else {
                        type = "File";
                }
                int iType = 1, iFilename = 2;
                int iRow = query.addRow() ;
                query.setData( iRow, iType, type ) ;
                query.setData( iRow, iFilename, dirItem ) ;
        }
}

---/code----

Hope someone finds it useful, though it didn't take long to write, (I
found the resursion bit in an online example)

-----Original Message-----
From: Calvin Ward [mailto:[EMAIL PROTECTED] 
Sent: 18 June 2003 12:23
To: CF-Talk
Subject: Recursive Directory - ColdFusion Component 


Has anyone made one of these?

Calvin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to