mirror of
https://github.com/holub/mame
synced 2025-04-18 22:49:58 +03:00
Mostly revert "Create console history file in homepath (#8026)"
The change to make the console plugin work is preserved.
This reverts commit 25137717c9
.
This commit is contained in:
parent
075d934ff4
commit
fab84e8d2b
@ -1,4 +1,3 @@
|
||||
local util = require("util")
|
||||
local lib = {}
|
||||
|
||||
local function get_settings_path()
|
||||
@ -71,7 +70,7 @@ function lib:save_settings(buttons)
|
||||
local path = get_settings_path()
|
||||
local attr = lfs.attributes(path)
|
||||
if not attr then
|
||||
util.mkdir_recursive(path)
|
||||
lfs.mkdir(path)
|
||||
elseif attr.mode ~= 'directory' then
|
||||
return
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- license:BSD-3-Clause
|
||||
-- copyright-holders:Miodrag Milanovic
|
||||
_G.lfs = require("lfs")
|
||||
require('lfs')
|
||||
|
||||
_G._ = emu.lang_translate
|
||||
_G.emu.plugin = {} -- table to contain plugin interfaces
|
||||
|
@ -72,7 +72,6 @@ exports.license = "The BSD 3-Clause License"
|
||||
exports.author = { name = "Carl" }
|
||||
|
||||
local cheat = exports
|
||||
local util = require("util")
|
||||
|
||||
function cheat.set_folder(path)
|
||||
cheat.path = path
|
||||
@ -160,7 +159,7 @@ function cheat.startplugin()
|
||||
local path = emu.subst_env(manager.machine.options.entries.cheatpath:value():match("([^;]+)"))
|
||||
local attr = lfs.attributes(path)
|
||||
if not attr then
|
||||
util.mkdir_recursive(path)
|
||||
lfs.mkdir(path)
|
||||
elseif attr.mode ~= "directory" then -- uhhh?
|
||||
return
|
||||
end
|
||||
@ -168,7 +167,7 @@ function cheat.startplugin()
|
||||
local softpath = path .. "/" .. cheatname:match("([^/]+)")
|
||||
local attr = lfs.attributes(softpath)
|
||||
if not attr then
|
||||
util.mkdir_recursive(softpath)
|
||||
lfs.mkdir(softpath)
|
||||
elseif attr.mode ~= "directory" then -- uhhh?
|
||||
return
|
||||
end
|
||||
|
@ -13,8 +13,6 @@ local history_file = "console_history"
|
||||
|
||||
local history_fullpath = nil
|
||||
|
||||
local util = require("util")
|
||||
|
||||
function console.startplugin()
|
||||
local conth = emu.thread()
|
||||
local ln_started = false
|
||||
@ -300,8 +298,7 @@ end
|
||||
setmetatable(console, {
|
||||
__gc = function ()
|
||||
if history_fullpath then
|
||||
util.create_parent_dirs(history_fullpath)
|
||||
local ln = require("linenoise")
|
||||
local ln = require("linenoise")
|
||||
ln.savehistory(history_fullpath)
|
||||
end
|
||||
end})
|
||||
|
@ -1,8 +1,6 @@
|
||||
-- to use this get the package from http://greatstone.free.fr/hi2txt/
|
||||
-- extract the hi2txt.zip and place it in your history path
|
||||
|
||||
local util = require("util")
|
||||
|
||||
local dat = {}
|
||||
local env = {}
|
||||
local output
|
||||
@ -1208,7 +1206,7 @@ function dat.check(set, softlist)
|
||||
local scrpath = path:match("[^;]*") .. "/"
|
||||
local scrfile = io.open(scrpath .. set .. ".lua", "w+")
|
||||
if not scrfile then
|
||||
util.mkdir_recursive(scrpath)
|
||||
lfs.mkdir(scrpath)
|
||||
scrfile = io.open(scrpath .. set .. ".lua", "w+")
|
||||
end
|
||||
if scrfile then
|
||||
|
@ -1,7 +1,6 @@
|
||||
local sql = require("lsqlite3")
|
||||
local datfile = {}
|
||||
local db
|
||||
local util = require("util")
|
||||
|
||||
local function check_db(msg)
|
||||
if db:errcode() > sql.OK then
|
||||
@ -13,10 +12,7 @@ do
|
||||
local dbpath = emu.subst_env(mame_manager.ui.options.entries.historypath:value():match("([^;]+)"))
|
||||
db = sql.open(dbpath .. "/history.db")
|
||||
if not db then
|
||||
local success, err = util.mkdir_recursive(dbpath)
|
||||
if not success then
|
||||
emu.print_error("Unable to create parent directories for history database: " .. err)
|
||||
end
|
||||
lfs.mkdir(dbpath)
|
||||
db = sql.open(dbpath .. "/history.db")
|
||||
if not db then
|
||||
emu.print_error("Unable to create history.db\n")
|
||||
|
@ -12,7 +12,6 @@ exports.description = "Hiscore"
|
||||
exports.license = "WTFPL license"
|
||||
exports.author = { name = "borgar@borgar.net" }
|
||||
local hiscore = exports
|
||||
local util = require("util")
|
||||
|
||||
local hiscore_plugin_path = ""
|
||||
|
||||
@ -172,7 +171,7 @@ function hiscore.startplugin()
|
||||
local output = io.open(get_file_name(), "wb");
|
||||
if not output then
|
||||
-- attempt to create the directory, and try again
|
||||
util.mkdir_recursive( hiscore_path );
|
||||
lfs.mkdir( hiscore_path );
|
||||
output = io.open(get_file_name(), "wb");
|
||||
end
|
||||
emu.print_verbose("hiscore: write_scores output")
|
||||
|
@ -25,7 +25,6 @@ exports.license = "The BSD 3-Clause License"
|
||||
exports.author = { name = "Carl" }
|
||||
|
||||
local portname = exports
|
||||
local util = require("util")
|
||||
|
||||
function portname.startplugin()
|
||||
local json = require("json")
|
||||
@ -130,7 +129,7 @@ function portname.startplugin()
|
||||
local function check_path(path)
|
||||
local attr = lfs.attributes(path)
|
||||
if not attr then
|
||||
util.mkdir_recursive(path)
|
||||
lfs.mkdir(path)
|
||||
if not lfs.attributes(path) then
|
||||
manager.machine:popmessage(_("Failed to save input name file"))
|
||||
emu.print_verbose("portname: unable to create path " .. path .. "\n")
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- license:BSD-3-Clause
|
||||
-- copyright-holders:Carl
|
||||
local util = require('util')
|
||||
require('lfs')
|
||||
local sqlite3 = require('lsqlite3')
|
||||
local exports = {}
|
||||
exports.name = "timer"
|
||||
@ -44,7 +44,7 @@ function timer.startplugin()
|
||||
save()
|
||||
end
|
||||
timer_started = true
|
||||
util.mkdir_recursive(dir .. '/timer')
|
||||
lfs.mkdir(dir .. '/timer')
|
||||
local db = assert(sqlite3.open(timer_db))
|
||||
local found=false
|
||||
db:exec([[select * from sqlite_master where name='timer';]], function(...) found=true return 0 end)
|
||||
|
@ -1,55 +0,0 @@
|
||||
local lfs = require("lfs")
|
||||
|
||||
-- Returns true if dirname is an existing directory, false if not a directory,
|
||||
-- or nil, an error message and a system dependent error code on error.
|
||||
local function is_dir(dirname)
|
||||
local ret, err, code = lfs.attributes(dirname, "mode")
|
||||
if ret == nil then
|
||||
return ret, err, code
|
||||
else
|
||||
return ret == "directory"
|
||||
end
|
||||
end
|
||||
|
||||
-- Get the directory name for the file.
|
||||
local function dirname(filename)
|
||||
if filename == "/" then
|
||||
return "/"
|
||||
end
|
||||
local parent = filename:match("(.*)/.")
|
||||
if parent then
|
||||
if parent == "" then
|
||||
parent = "/"
|
||||
end
|
||||
return parent
|
||||
end
|
||||
return "."
|
||||
end
|
||||
|
||||
-- Create dir and parents for dir if needed. Returns true on success,
|
||||
-- nil, an error message and a system dependent error code on error.
|
||||
local function mkdir_recursive(dir)
|
||||
local ret, err, code = is_dir(dir)
|
||||
if ret == true then
|
||||
return true
|
||||
end
|
||||
local parent = dirname(dir)
|
||||
local ret, err, code = mkdir_recursive(parent)
|
||||
if not ret then
|
||||
return ret, err, code
|
||||
end
|
||||
return lfs.mkdir(dir)
|
||||
end
|
||||
|
||||
-- Create the parents of the file recursively if needed, returns true on success,
|
||||
-- or nil, an error message and a system dependent error code on error.
|
||||
local function create_parent_dirs(filename)
|
||||
local parent = dirname(filename)
|
||||
return mkdir_recursive(parent)
|
||||
end
|
||||
|
||||
return {
|
||||
dirname = dirname,
|
||||
mkdir_recursive = mkdir_recursive,
|
||||
create_parent_dirs = create_parent_dirs
|
||||
}
|
Loading…
Reference in New Issue
Block a user