mirror of
https://github.com/LDDestroier/CC/
synced 2025-05-24 16:24:05 +00:00
Added -E option for auto extractors
Auto extractors will now only self-delete if the output directory is the same path as the extractor itself. Also, you can specify where an auto extractor will extract to with the -E [path] option.
This commit is contained in:
parent
920def0ae7
commit
c904ce25e9
89
progdor2.lua
89
progdor2.lua
@ -129,7 +129,7 @@ local function dc(data)
|
|||||||
prefix = ""
|
prefix = ""
|
||||||
else
|
else
|
||||||
entry = dic[currCode]
|
entry = dic[currCode]
|
||||||
if entry then--exists in dictionary
|
if entry then -- exists in dictionary
|
||||||
ch = entry:sub(1, 1)
|
ch = entry:sub(1, 1)
|
||||||
result[#result + 1] = entry
|
result[#result + 1] = entry
|
||||||
if prefix ~= "" then
|
if prefix ~= "" then
|
||||||
@ -214,6 +214,7 @@ local argData = {
|
|||||||
["-P"] = false, -- include Progdor2 file
|
["-P"] = false, -- include Progdor2 file
|
||||||
["-S"] = false, -- use skynet
|
["-S"] = false, -- use skynet
|
||||||
["-e"] = false, -- automatic self-extractor
|
["-e"] = false, -- automatic self-extractor
|
||||||
|
["-E"] = "string", -- specify output folder in self-extractor code
|
||||||
["-s"] = false, -- silent
|
["-s"] = false, -- silent
|
||||||
["-a"] = false, -- use as API with require, also makes silent
|
["-a"] = false, -- use as API with require, also makes silent
|
||||||
["-c"] = false, -- use CCA compression
|
["-c"] = false, -- use CCA compression
|
||||||
@ -234,18 +235,19 @@ if #argErrors > 0 then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local pastebinGet = argList["-pb"] -- string, pastebin code
|
local pastebinGet = argList["-pb"] -- string, pastebin code
|
||||||
local directDownload = argList["-dd"] -- string, download URL
|
local directDownload = argList["-dd"] -- string, download URL
|
||||||
local mainFile = argList["-m"] -- string, main executable file
|
local mainFile = argList["-m"] -- string, main executable file
|
||||||
local pastebinUpload = argList["-PB"] -- boolean
|
local pastebinUpload = argList["-PB"] -- boolean
|
||||||
local selfExtractor = argList["-e"] -- boolean
|
local selfExtractor = argList["-e"] -- boolean
|
||||||
local silent = argList["-s"] -- boolean
|
local selfExtractorFolder = argList["-E"] -- string, folder output for self extractor code
|
||||||
local useCompression = argList["-c"] -- boolean
|
local silent = argList["-s"] -- boolean
|
||||||
local justOverwrite = argList["-o"] -- boolean
|
local useCompression = argList["-c"] -- boolean
|
||||||
local allowReadOnly = argList["-R"] -- boolean
|
local justOverwrite = argList["-o"] -- boolean
|
||||||
local allowPackPD = argList["-P"] -- boolean
|
local allowReadOnly = argList["-R"] -- boolean
|
||||||
local useSkynet = argList["-S"] -- boolean
|
local allowPackPD = argList["-P"] -- boolean
|
||||||
local trMode = argList["-t"] and "transmit" or (argList["-r"] and "receive" or "normal")
|
local useSkynet = argList["-S"] -- boolean
|
||||||
|
local trMode = argList["-t"] and "transmit" or (argList["-r"] and "receive" or "normal")
|
||||||
|
|
||||||
local skynet
|
local skynet
|
||||||
|
|
||||||
@ -296,6 +298,7 @@ local function showHelp(verboseHelp)
|
|||||||
" -PB : Upload to pastebin.", -- added
|
" -PB : Upload to pastebin.", -- added
|
||||||
" -dd [download URL] : Download from URL.", -- added
|
" -dd [download URL] : Download from URL.", -- added
|
||||||
" -e : Adds on self-extractor code to archive.", -- added
|
" -e : Adds on self-extractor code to archive.", -- added
|
||||||
|
" -E [folder] : Extractor extracts to folder", -- added
|
||||||
" -s : Silences all terminal writing", -- added
|
" -s : Silences all terminal writing", -- added
|
||||||
" -S : Use skynet when transmitting/receiving.", -- added
|
" -S : Use skynet when transmitting/receiving.", -- added
|
||||||
" -t : Transmit a folder/file.", -- added
|
" -t : Transmit a folder/file.", -- added
|
||||||
@ -307,8 +310,6 @@ local function showHelp(verboseHelp)
|
|||||||
" -m : Specify main executable file in archive.", -- added
|
" -m : Specify main executable file in archive.", -- added
|
||||||
" -i : Inspect archive without extracting.", -- added
|
" -i : Inspect archive without extracting.", -- added
|
||||||
" -o : Overwrite files without asking.", -- added
|
" -o : Overwrite files without asking.", -- added
|
||||||
"",
|
|
||||||
" This Progdor has Super Cow Powers." -- not actually added
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
helpInfo = {
|
helpInfo = {
|
||||||
@ -927,21 +928,71 @@ elseif mode == "pack" then
|
|||||||
sPrint("Tacking on self-extractor.")
|
sPrint("Tacking on self-extractor.")
|
||||||
archive = ([[
|
archive = ([[
|
||||||
local tArg = {...}
|
local tArg = {...}
|
||||||
local outputPath, file = tArg[1] and fs.combine(shell.dir(), tArg[1]) or ]] .. ((defaultAutoExtractPath and ("\"" .. defaultAutoExtractPath .. "\"")) or "shell.getRunningProgram()") .. [[
|
local selfDelete = false -- if true, deletes extractor after running
|
||||||
|
local file
|
||||||
|
local outputPath = ]] ..
|
||||||
|
|
||||||
|
(selfExtractorFolder and (
|
||||||
|
"shell.resolve(\"" .. selfExtractorFolder .. "\")"
|
||||||
|
) or (
|
||||||
|
"tArg[1] and shell.resolve(tArg[1]) or ]]" .. ((defaultAutoExtractPath and ("\"" .. defaultAutoExtractPath .. "\"")) or "shell.getRunningProgram()")
|
||||||
|
)) .. [[
|
||||||
|
|
||||||
local safeColorList = {[colors.white] = true,[colors.lightGray] = true,[colors.gray] = true,[colors.black] = true}
|
local safeColorList = {[colors.white] = true,[colors.lightGray] = true,[colors.gray] = true,[colors.black] = true}
|
||||||
local stc = function(color) if (term.isColor() or safeColorList[color]) then term.setTextColor(color) end end
|
local stc = function(color) if (term.isColor() or safeColorList[color]) then term.setTextColor(color) end end
|
||||||
|
local choice = function()
|
||||||
|
local input = "yn"
|
||||||
|
write("[")
|
||||||
|
for a = 1, #input do
|
||||||
|
write(input:sub(a,a):upper())
|
||||||
|
if a < #input then
|
||||||
|
write(",")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print("]?")
|
||||||
|
local evt,char
|
||||||
|
repeat
|
||||||
|
evt,char = os.pullEvent("char")
|
||||||
|
until string.find(input:lower(),char:lower())
|
||||||
|
if verbose then
|
||||||
|
print(char:upper())
|
||||||
|
end
|
||||||
|
local pos = string.find(input:lower(), char:lower())
|
||||||
|
return pos, char:lower()
|
||||||
|
end
|
||||||
local archive = textutils.unserialize(]] ..
|
local archive = textutils.unserialize(]] ..
|
||||||
|
|
||||||
textutils.serialize(archive) ..
|
textutils.serialize(archive) ..
|
||||||
|
|
||||||
[[)
|
[[)
|
||||||
if fs.isReadOnly(outputPath) then
|
if fs.isReadOnly(outputPath) then
|
||||||
error("Output path is read-only.")
|
error("Output path is read-only. Abort.")
|
||||||
elseif fs.getFreeSpace(outputPath) <= #archive then
|
elseif fs.getFreeSpace(outputPath) <= #archive then
|
||||||
error("Insufficient space.")
|
error("Insufficient space. Abort.")
|
||||||
|
end
|
||||||
|
|
||||||
|
]] .. ( justOverwrite and [[
|
||||||
|
if fs.exists(outputPath) and fs.combine("", outputPath) ~= "" then
|
||||||
|
fs.delete(outputPath)
|
||||||
|
end
|
||||||
|
]] or [[
|
||||||
|
if fs.exists(outputPath) and fs.combine("", outputPath) ~= "" then
|
||||||
|
print("File/folder already exists! Overwrite?")
|
||||||
|
stc(colors.lightGray)
|
||||||
|
print("(Use -o when making the extractor to always overwrite.)")
|
||||||
|
stc(colors.white)
|
||||||
|
if choice() ~= 1 then
|
||||||
|
error("Chose not to overwrite. Abort.")
|
||||||
|
else
|
||||||
|
fs.delete(outputPath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
) ..
|
||||||
|
[[
|
||||||
|
if selfDelete or (fs.combine("", outputPath) == shell.getRunningProgram()) then
|
||||||
|
fs.delete(shell.getRunningProgram())
|
||||||
end
|
end
|
||||||
fs.delete(shell.getRunningProgram()) -- saves space
|
|
||||||
for name, contents in pairs(archive.data) do
|
for name, contents in pairs(archive.data) do
|
||||||
stc(colors.lightGray)
|
stc(colors.lightGray)
|
||||||
write("'" .. name .. "'...")
|
write("'" .. name .. "'...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user