From d9cfdfa5d7c30f6fd3a0d2bcea60554f2b58de50 Mon Sep 17 00:00:00 2001 From: Skye Date: Mon, 5 Jan 2015 14:50:48 +0000 Subject: [PATCH 1/2] Add ability to save current EEPROM to file in flash.lua --- .../opencomputers/loot/OpenOS/bin/flash.lua | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua index f9474eb15..982858094 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua @@ -1,17 +1,41 @@ local component = require("component") local shell = require("shell") +local fs = require("filesystem") local args, options = shell.parse(...) if #args < 1 and not options.l then - io.write("Usage: flash [-ql] [] [label]\n") + io.write("Usage: flash [-qlr] [] [label]\n") io.write(" q: quiet mode, don't ask questions.\n") - io.write(" l: print current contents of installed EEPROM.") + io.write(" l: print current contents of installed EEPROM.\n") + io.write(" r: save the current contents of installed EEPROM to file.") return end +local eeprom = component.eeprom + if options.l then - io.write(component.eeprom.get()) + io.write(eeprom.get()) + return +end + +if options.r then + fileName = shell.resolve(args[1]) + if not options.q then + if fs.exists(fileName) then + io.write("Are you want to overwrite " .. fileName .. "?\n") + io.write("Type `y` to confirm.\n") + repeat + local response = io.read() + until response and response:lower():sub(1, 1) == "y" + end + io.write("Reading EEPROM " .. eeprom.address .. ".\n" ) + end + file = io.open(fileName, 'wb') + local bios = eeprom.get() + file:write(bios) + file:close() + if not options.q then io.write("All done!\nThe label is '" .. eeprom.getLabel() .. "'.\n") end return end @@ -26,8 +50,6 @@ if not options.q then io.write("Beginning to flash EEPROM.\n") end -local eeprom = component.eeprom - if not options.q then io.write("Flashing EEPROM " .. eeprom.address .. ".\n") io.write("Please do NOT power down or restart your computer during this operation!\n") @@ -52,4 +74,4 @@ end if not options.q then io.write("All done! You can remove the EEPROM and re-insert the previous one now.\n") -end \ No newline at end of file +end From ebb7ae5038293734f68f9cca358f143b7dbf5682 Mon Sep 17 00:00:00 2001 From: Skye Date: Mon, 5 Jan 2015 17:15:22 +0000 Subject: [PATCH 2/2] Fixed a typo in flash.lua "Are you want to overwrite?" --- .../resources/assets/opencomputers/loot/OpenOS/bin/flash.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua index 982858094..fbcdeef65 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/flash.lua @@ -23,7 +23,7 @@ if options.r then fileName = shell.resolve(args[1]) if not options.q then if fs.exists(fileName) then - io.write("Are you want to overwrite " .. fileName .. "?\n") + io.write("Are you sure you want to overwrite " .. fileName .. "?\n") io.write("Type `y` to confirm.\n") repeat local response = io.read()