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
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: Function to return the current directory

That's pretty cool.
Personally I would combine the two functions into one, considering they are almost identical.

A warning:
It chokes if you have a broken link in your cDirectory. I spent too long trying to figure that one out =o)

EDIT: Here a fix for the broken link (and any other file that can't be read):

Code:
for file in lfs.dir(path) do
        local readtest=io.open(file)
        if file ~= "." and file ~= ".." and readtest then
            readtest:close()


EDIT2: Oddly enough, it still works for files that have no read permission for the user, even without the readtest.
So I'm guessing a broken link is a special case.

This post was last modified: 08-01-2007 01:14 PM by mikshaw.

08-01-2007 12:45 PM
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 - mikshaw - 08-01-2007 12:45 PM

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

Forum Jump: