Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better osx support and EMCO tab change event #26

Merged
merged 3 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/resources/demontools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,39 @@ local DemonTools = {}
local cheatConsole = Geyser.MiniConsole:new({name = "DemonnicCheatConsole", width = 4000, wrapWidth = 10000, color = "black"})
cheatConsole:hide()
local function exists(path)
local ok, err, code = os.rename(path, path)
if not ok and code == 13 then
path = path:gsub([[\]], "/")
if path:ends("/") then
path = path:sub(1,-2)
end
local ok, err, code = lfs.attributes(path)
if ok then
return true
end
return ok, err
if err:lower():find("no such file or directory") then
return false
end
return ok, err, code
end

local function isWindows()
return package.config:sub(1, 1) == [[\]]
end

local function isDir(path)
path = path:gsub("\\", "/")
if not path:ends("/") then
path = path .. "/"
if not exists(path) then return false end
path = path:gsub([[\]], "/")
if path:ends("/") then
path = path:sub(1,-2)
end
return exists(path)
local ok, err, code = lfs.attributes(path, "mode")
if ok then
if ok == "directory" then
return true
else
return false
end
end
return ok, err, code
end

local function mkdir_p(path)
Expand Down
1 change: 1 addition & 0 deletions src/resources/emco.lua
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ function EMCO:switchTab(tabName)
end
self.mc[tabName]:show()
self.currentTab = tabName
raiseEvent("EMCO tab change", self.name, oldTab, tabName)
end

function EMCO:createComponentsForTab(tabName)
Expand Down
7 changes: 5 additions & 2 deletions src/resources/loggingconsole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ end
function LoggingConsole:writeToLog(str)
local fileName = self:getFullFilename()
self:createPathIfNotExists()
if self:getExtension() == "html" and not io.exists(fileName) then
str = htmlHeader .. str
if self:getExtension() == "html" then
if not io.exists(fileName) then
str = htmlHeader .. str
end
str = str .. "\n" -- html doesn't care about the extra whitespace, but it makes the raw file much easier to read
end
local file, err = io.open(fileName, "a")
if not file then
Expand Down