News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Function to return the current directory
Author Message
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #1
RE: Function to return the current directory

Hmm I thought I posted this code before going out

Code:
cDirectory=lfs.currentdir()


function listFolders(path)
local folderList=""
    for file in lfs.dir(path) do
        
        if file ~= "." and file ~= ".." then
            local f = path..'/'..file
            local attr = lfs.attributes (f)
            assert (type(attr) == "table")
             if attr.mode == "directory" then
              
             folderList=folderList..file.."\n"
             end  
        end
    end
    return folderList
end

function listFiles(path)
local fileList=""
    for file in lfs.dir(path) do
        if file ~= "." and file ~= ".." then
            local f = path..'/'..file
            local attr = lfs.attributes (f)
            assert (type(attr) == "table")
             if attr.mode == "file" then
              fileList=fileList..file.."\n"
              end  
        end
    end
    return fileList
end


a=listFolders(cDirectory)
print(a)
b=listFiles(cDirectory)
print(b)

08-01-2007 10:42 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
RE: Function to return the current directory - iGame3D - 08-01-2007 10:42 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: