aboutsummaryrefslogtreecommitdiff
path: root/plugins/lastproject.lua
blob: 5fb23bd22b7db3ccd66bfe2ef2803f56f73dd224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local core = require "core"

local last_project_filename = EXEDIR .. PATHSEP .. ".lite_last_project"


-- load last project path
local fp = io.open(last_project_filename)
local project_path
if fp then
    project_path = fp:read("*a")
    fp:close()
end


-- save current project path
local fp = io.open(last_project_filename, "w")
if nil ~= fp then
    fp:write(system.absolute_path ".")
    fp:close()
end


-- restart using last project path if we had no commandline arguments and could
-- find a last-project file
if #ARGS == 1 and project_path then
    system.exec(string.format("%s %q", EXEFILE, project_path))
    core.quit(true)
end