259 posts
Posted 31 August 2013 - 02:32 AM
I know about fs.exists(string path) But if I'm in the main directory, and I want to see if you can run "dance" for example, it will return false. Is there a way to see if that file exists on the computer?
331 posts
Posted 31 August 2013 - 05:03 AM
this is just from my head
function check(dir, file)
f = fs.list(dir)
for k, v in pairs(f) do
local path = fs.combine(dir, v)
if not fs.isReadOnly(path) then
if fs.isDir(path)
check(path) -- check the directory
else
if path == file then
return true
end
end
end
end
that should work
259 posts
Posted 31 August 2013 - 05:44 PM
this is just from my head
function check(dir, file)
f = fs.list(dir)
for k, v in pairs(f) do
local path = fs.combine(dir, v)
if not fs.isReadOnly(path) then
if fs.isDir(path)
check(path) -- check the directory
else
if path == file then
return true
end
end
end
end
that should work
Missing one then I'm sure you mean "if fs.isDir(path) then" I'll post more when I have more info on if it worked or not. I'm kinda swamped with stuff to do at the moment.
504 posts
Location
Seattle, WA
Posted 31 August 2013 - 06:08 PM
this is just from my head
function check(dir, file)
f = fs.list(dir)
for k, v in pairs(f) do
local path = fs.combine(dir, v)
if not fs.isReadOnly(path) then
if fs.isDir(path)
check(path) -- check the directory
else
if path == file then
return true
end
end
end
end
You'll also need to pass 'file' to the every recursive call of 'check'.
8543 posts
Posted 31 August 2013 - 08:24 PM
It sounds kind of like shell.resolveProgram is what you're looking for, unless you really need to find it in any directory, rather than just determining if the string input resolves to a file on the path or in the current directory.