add numeric suffix to stashed files
This commit is contained in:
parent
bd82e5ecbb
commit
ab11782662
|
@ -36,9 +36,11 @@ draw_file_dialog = function()
|
|||
-- on the first frame after dialog is enabled
|
||||
Stash_directory_contents = directory_contents(Stash_directory)
|
||||
end
|
||||
y = y+Line_height+20
|
||||
App.color{r=1, g=1, b=1}
|
||||
g.print('stashed files:', Menu_left+10, y)
|
||||
y = y+Line_height+5
|
||||
y = add_stash_files_to_dialog(Menu_left+10, y)
|
||||
if #Stash_directory_contents > 0 then
|
||||
y = y+Line_height+20
|
||||
App.color{r=1, g=1, b=1}
|
||||
g.print('stashed files:', Menu_left+10, y)
|
||||
y = y+Line_height+5
|
||||
y = add_stash_files_to_dialog(Menu_left+10, y)
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
refresh_directory_contents = function()
|
||||
Directory_contents = {}
|
||||
local filenames = App.files(Directory)
|
||||
for _,filename in ipairs(filenames) do
|
||||
local file_info = App.file_info(Directory..filename)
|
||||
if file_info.type == 'file' then
|
||||
table.insert(Directory_contents, filename)
|
||||
end
|
||||
end
|
||||
table.sort(Directory_contents)
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
reset_file_dialog_state = function()
|
||||
Show_file_dialog = false
|
||||
Directory_contents = nil
|
||||
Stash_directory_contents = nil
|
||||
File_dialog_callback = nil
|
||||
File_dialog_input_text = ''
|
||||
File_dialog_input_draw_suffix = ''
|
||||
|
|
|
@ -3,9 +3,11 @@ stash_pane = function(pane)
|
|||
local contents, error = love.filesystem.read(src)
|
||||
if not contents then return print_to_output(error) end
|
||||
love.filesystem.createDirectory(Stash_directory)
|
||||
local dest = Stash_directory..pane.filename
|
||||
local stash_filename = next_stash_filename(pane.filename)
|
||||
local dest = Stash_directory..stash_filename
|
||||
local success, error = love.filesystem.write(dest, contents)
|
||||
if not success then return print_to_output(error) end
|
||||
love.filesystem.remove(src)
|
||||
pane.filename = stash_filename
|
||||
pane.is_stash = true
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
next_stash_filename = function(root)
|
||||
local i = 1
|
||||
while true do
|
||||
local filename = root..'.'..tostring(i)
|
||||
if not file_exists(Stash_directory..filename) then
|
||||
return filename
|
||||
end
|
||||
i = i+1
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue