local tArgs = {...} local modem = peripheral.wrap("right") local function findFile(fileName) local function recurFile(directory,searchTerm) for a,v in pairs(fs.list(directory)) do --# Error was here, forgot fs.list if fs.isDir(v) then local fnd = recurFile(fs.combine(directory,v),searchTerm) if fnd ~= nil then return fnd end elseif v == searchTerm then return {true,fs.combine(directory,v)} end end end for a,v in pairs(modem.getNamesRemote()) do if peripheral.getType(v) == "drive" then local found = recurFile(disk.getMountPath(v),fileName) if found ~= nil then return unpack(found) end end end end local found,path = findFile(tArgs[1]) if found then print(path) end
2
Search engine across multiple disk drives?
Started by Kangaroo2K1, Apr 27 2015 04:36 AM
networking help
29 replies to this topic
#21
Posted 01 May 2015 - 03:34 AM
Small oversight on my spot, didn't do it all correctly.
#22
Posted 02 May 2015 - 12:56 PM
Dragon53535, on 01 May 2015 - 03:34 AM, said:
Small oversight on my spot, didn't do it all correctly.
local tArgs = {...} local modem = peripheral.wrap("right") local function findFile(fileName) local function recurFile(directory,searchTerm) for a,v in pairs(fs.list(directory)) do --# Error was here, forgot fs.list if fs.isDir(v) then local fnd = recurFile(fs.combine(directory,v),searchTerm) if fnd ~= nil then return fnd end elseif v == searchTerm then return {true,fs.combine(directory,v)} end end end for a,v in pairs(modem.getNamesRemote()) do if peripheral.getType(v) == "drive" then local found = recurFile(disk.getMountPath(v),fileName) if found ~= nil then return unpack(found) end end end end local found,path = findFile(tArgs[1]) if found then print(path) end
#23
Posted 02 May 2015 - 02:34 PM
Just to make sure, you're calling the program with an extra word right?
#24
Posted 02 May 2015 - 04:43 PM
Dragon53535, on 02 May 2015 - 02:34 PM, said:
Just to make sure, you're calling the program with an extra word right?
#25
Posted 02 May 2015 - 05:13 PM
And the modem is on the right?
#27
Posted 02 May 2015 - 08:16 PM
Please post the full error, uncluding the line number.
#28
Posted 03 May 2015 - 02:27 AM
flaghacker, on 02 May 2015 - 08:16 PM, said:
Please post the full error, uncluding the line number.
Edited by Kangaroo2K1, 03 May 2015 - 02:27 AM.
#29
Posted 03 May 2015 - 10:57 PM
Ugh, it's not your fault. Silly getMountPath returns nil if you don't have a floppy in it. Give me a minute to fix it again with the correct line.
local tArgs = {...} local modem = peripheral.wrap("right") local function findFile(fileName) local function recurFile(directory,searchTerm) for a,v in pairs(fs.list(directory)) do --# Error was here, forgot fs.list if fs.isDir(v) then local fnd = recurFile(fs.combine(directory,v),searchTerm) if fnd ~= nil then return fnd end elseif v == searchTerm then return {true,fs.combine(directory,v)} end end end for a,v in pairs(modem.getNamesRemote()) do if peripheral.getType(v) == "drive" and disk.hasData(v) then --# this should fix the problem local found = recurFile(disk.getMountPath(v),fileName) if found ~= nil then return unpack(found) end end end end local found,path = findFile(tArgs[1]) if found then print(path) end
Edited by Dragon53535, 03 May 2015 - 10:58 PM.
#30
Posted 04 May 2015 - 03:01 AM
Dragon53535, on 03 May 2015 - 10:57 PM, said:
Ugh, it's not your fault. Silly getMountPath returns nil if you don't have a floppy in it. Give me a minute to fix it again with the correct line.
local tArgs = {...} local modem = peripheral.wrap("right") local function findFile(fileName) local function recurFile(directory,searchTerm) for a,v in pairs(fs.list(directory)) do --# Error was here, forgot fs.list if fs.isDir(v) then local fnd = recurFile(fs.combine(directory,v),searchTerm) if fnd ~= nil then return fnd end elseif v == searchTerm then return {true,fs.combine(directory,v)} end end end for a,v in pairs(modem.getNamesRemote()) do if peripheral.getType(v) == "drive" and disk.hasData(v) then --# this should fix the problem local found = recurFile(disk.getMountPath(v),fileName) if found ~= nil then return unpack(found) end end end end local found,path = findFile(tArgs[1]) if found then print(path) end
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users