96 posts
Location
Dark Side of The Moon
Posted 21 February 2012 - 01:48 AM
Hello there. I am working on a bootdisk for recovering files.
here is the harddisk copyier code
print("What side do you want to copy to?")
side = io.read()
path = disk.getMountPath(side)
if path then
print("Copying")
for i, v in pairs(fs.list("/")) do
fs.copy("/"..v,path.."/"..v)
end
print("Done")
fs.delete(path.."/".."startup")
fs.delete(path.."/".."rom")
read()
disk.eject(side)
os.reboot()
else
print("Not a valid disk")
end
it works all well except for the fs.delete(path.."/".."rom")
the rom folder gets copied to the disk
Is there anyway i can fix that?
Thanks
454 posts
Location
London
Posted 21 February 2012 - 02:13 AM
Hello there. I am working on a bootdisk for recovering files.
here is the harddisk copyier code
print("What side do you want to copy to?")
side = io.read()
path = disk.getMountPath(side)
if path then
print("Copying")
for i, v in pairs(fs.list("/")) do
fs.copy("/"..v,path.."/"..v)
end
print("Done")
fs.delete(path.."/".."startup")
fs.delete(path.."/".."rom")
read()
disk.eject(side)
os.reboot()
else
print("Not a valid disk")
end
it works all well except for the fs.delete(path.."/".."rom")
the rom folder gets copied to the disk
Is there anyway i can fix that?
Thanks
Simply check for rom/ during copying:
for i, v in pairs(fs.list("/")) do
if v ~= "rom" and v:sub(1, 4) ~= "rom/" then
fs.copy("/"..v,path.."/"..v)
end
end
Something like that should work.
If you can't delete disk/rom, then that's a bug! I'll test it and report for you.
Edit: I'm able to delete disk/rom on 1.3; not sure about 1.21.
Edited on 21 February 2012 - 01:36 AM
96 posts
Location
Dark Side of The Moon
Posted 21 February 2012 - 03:10 AM
Thanks dude! I am on 1.21
96 posts
Location
Dark Side of The Moon
Posted 21 February 2012 - 06:33 PM
When i try to use the harddisk copyier to copy the hdd to a floppy i get this
454 posts
Location
London
Posted 21 February 2012 - 07:04 PM
Well then, add another check to see if you're trying to copy disk/ into disk/!
96 posts
Location
Dark Side of The Moon
Posted 21 February 2012 - 07:18 PM
I tried
elseif input == "2" then
print("What side do you want to copy to?")
side = io.read()
path = disk.getMountPath(side)
if path then
print("Copying")
for i, v in pairs(fs.list("/")) do -- Patched by Advert
if v ~= "rom" and ~= "disk" and ~= "startup" and v:sub(1, 4) ~= "rom/" and ~= "disk/" ans ~= "startup" then
fs.copy("/"..v,path.."/"..v)
end
end
print("Done")
read()
disk.eject(side)
os.reboot()
else
print("Not a valid disk")
end
I am not the best at Lua
454 posts
Location
London
Posted 21 February 2012 - 07:44 PM
I tried
elseif input == "2" then
print("What side do you want to copy to?")
side = io.read()
path = disk.getMountPath(side)
if path then
print("Copying")
for i, v in pairs(fs.list("/")) do -- Patched by Advert
if v ~= "rom" and ~= "disk" and ~= "startup" and v:sub(1, 4) ~= "rom/" and ~= "disk/" ans ~= "startup" then
fs.copy("/"..v,path.."/"..v)
end
end
print("Done")
read()
disk.eject(side)
os.reboot()
else
print("Not a valid disk")
end
I am not the best at Lua
You need to specify both sides to your ~= checks:
if v ~= "rom" and v ~= "disk" and v ~= "startup" and v:sub(1, 4) ~= "rom/" and v:sub(1, 4) ~= "disk/" and v:sub(1, 4) ~= "startup" then
96 posts
Location
Dark Side of The Moon
Posted 21 February 2012 - 11:21 PM
Thank You! I got my whole recovery kernel done now