bugfix: path munging on Windows

This commit is contained in:
Kartik K. Agaram 2022-09-10 19:23:34 -07:00
parent 06c784b576
commit 511db8cffd
4 changed files with 8 additions and 6 deletions

View File

@ -94,7 +94,7 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c
right = right,
width = right-left,
filename = love.filesystem.getUserDirectory()..'/lines.txt',
filename = love.filesystem.getUserDirectory()..'/lines.txt', -- '/' should work even on Windows
next_save = nil,
-- undo

View File

@ -141,8 +141,9 @@ function run.settings()
Settings.x, Settings.y, Settings.displayindex = love.window.getPosition()
end
local filename = Editor_state.filename
if filename:sub(1,1) ~= '/' then
filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows
local os_path_separator = package.config:sub(1,1)
if filename:sub(1,1) ~= os_path_separator then
filename = love.filesystem.getWorkingDirectory()..os_path_separator..filename
end
return {
x=Settings.x, y=Settings.y, displayindex=Settings.displayindex,

View File

@ -257,8 +257,9 @@ function source.settings()
Settings.source.x, Settings.source.y, Settings.source.displayindex = love.window.getPosition()
end
local filename = Editor_state.filename
if filename:sub(1,1) ~= '/' then
filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows
local os_path_separator = package.config:sub(1,1)
if filename:sub(1,1) ~= os_path_separator then
filename = love.filesystem.getWorkingDirectory()..os_path_separator..filename
end
--? print('saving source settings', Settings.source.x, Settings.source.y, Settings.source.displayindex)
return {

View File

@ -100,7 +100,7 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c
right = right,
width = right-left,
filename = love.filesystem.getUserDirectory()..'/lines.txt',
filename = love.filesystem.getUserDirectory()..'/lines.txt', -- '/' should work even on Windows
next_save = nil,
-- undo