mirror of
https://github.com/holub/mame
synced 2025-04-29 03:20:50 +03:00
Merge remote-tracking branch 'origin/master' into netlist_dev
This commit is contained in:
commit
798bb79567
@ -461,7 +461,6 @@ project ("ocore_" .. _OPTIONS["osd"])
|
|||||||
MAME_DIR .. "src/osd/strconv.h",
|
MAME_DIR .. "src/osd/strconv.h",
|
||||||
MAME_DIR .. "src/osd/osdsync.cpp",
|
MAME_DIR .. "src/osd/osdsync.cpp",
|
||||||
MAME_DIR .. "src/osd/osdsync.h",
|
MAME_DIR .. "src/osd/osdsync.h",
|
||||||
MAME_DIR .. "src/osd/sdl/sdldir.cpp",
|
|
||||||
MAME_DIR .. "src/osd/modules/osdmodule.cpp",
|
MAME_DIR .. "src/osd/modules/osdmodule.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/osdmodule.h",
|
MAME_DIR .. "src/osd/modules/osdmodule.h",
|
||||||
MAME_DIR .. "src/osd/modules/lib/osdlib_" .. SDLOS_TARGETOS .. ".cpp",
|
MAME_DIR .. "src/osd/modules/lib/osdlib_" .. SDLOS_TARGETOS .. ".cpp",
|
||||||
@ -470,6 +469,7 @@ project ("ocore_" .. _OPTIONS["osd"])
|
|||||||
|
|
||||||
if BASE_TARGETOS=="unix" then
|
if BASE_TARGETOS=="unix" then
|
||||||
files {
|
files {
|
||||||
|
MAME_DIR .. "src/osd/modules/file/posixdir.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/posixfile.cpp",
|
MAME_DIR .. "src/osd/modules/file/posixfile.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/posixfile.h",
|
MAME_DIR .. "src/osd/modules/file/posixfile.h",
|
||||||
MAME_DIR .. "src/osd/modules/file/posixptty.cpp",
|
MAME_DIR .. "src/osd/modules/file/posixptty.cpp",
|
||||||
@ -480,6 +480,7 @@ project ("ocore_" .. _OPTIONS["osd"])
|
|||||||
MAME_DIR .. "src/osd/windows",
|
MAME_DIR .. "src/osd/windows",
|
||||||
}
|
}
|
||||||
files {
|
files {
|
||||||
|
MAME_DIR .. "src/osd/modules/file/windir.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/winfile.cpp",
|
MAME_DIR .. "src/osd/modules/file/winfile.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/winfile.h",
|
MAME_DIR .. "src/osd/modules/file/winfile.h",
|
||||||
MAME_DIR .. "src/osd/modules/file/winptty.cpp",
|
MAME_DIR .. "src/osd/modules/file/winptty.cpp",
|
||||||
|
@ -244,13 +244,13 @@ project ("ocore_" .. _OPTIONS["osd"])
|
|||||||
MAME_DIR .. "src/osd/osdsync.cpp",
|
MAME_DIR .. "src/osd/osdsync.cpp",
|
||||||
MAME_DIR .. "src/osd/osdsync.h",
|
MAME_DIR .. "src/osd/osdsync.h",
|
||||||
MAME_DIR .. "src/osd/windows/main.cpp",
|
MAME_DIR .. "src/osd/windows/main.cpp",
|
||||||
MAME_DIR .. "src/osd/windows/windir.cpp",
|
|
||||||
MAME_DIR .. "src/osd/windows/winutf8.cpp",
|
MAME_DIR .. "src/osd/windows/winutf8.cpp",
|
||||||
MAME_DIR .. "src/osd/windows/winutf8.h",
|
MAME_DIR .. "src/osd/windows/winutf8.h",
|
||||||
MAME_DIR .. "src/osd/windows/winutil.cpp",
|
MAME_DIR .. "src/osd/windows/winutil.cpp",
|
||||||
MAME_DIR .. "src/osd/windows/winutil.h",
|
MAME_DIR .. "src/osd/windows/winutil.h",
|
||||||
MAME_DIR .. "src/osd/modules/osdmodule.cpp",
|
MAME_DIR .. "src/osd/modules/osdmodule.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/osdmodule.h",
|
MAME_DIR .. "src/osd/modules/osdmodule.h",
|
||||||
|
MAME_DIR .. "src/osd/modules/file/windir.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/winfile.cpp",
|
MAME_DIR .. "src/osd/modules/file/winfile.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/file/winfile.h",
|
MAME_DIR .. "src/osd/modules/file/winfile.h",
|
||||||
MAME_DIR .. "src/osd/modules/file/winptty.cpp",
|
MAME_DIR .. "src/osd/modules/file/winptty.cpp",
|
||||||
|
@ -271,7 +271,7 @@ READ32_MEMBER( nubus_image_device::image_super_r )
|
|||||||
|
|
||||||
WRITE32_MEMBER( nubus_image_device::file_cmd_w )
|
WRITE32_MEMBER( nubus_image_device::file_cmd_w )
|
||||||
{
|
{
|
||||||
const osd_directory_entry *dp;
|
const osd::directory::entry *dp;
|
||||||
char fullpath[1024];
|
char fullpath[1024];
|
||||||
UINT64 filesize;
|
UINT64 filesize;
|
||||||
|
|
||||||
@ -290,11 +290,10 @@ WRITE32_MEMBER( nubus_image_device::file_cmd_w )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kFileCmdGetFirstListing:
|
case kFileCmdGetFirstListing:
|
||||||
if(filectx.dirp) osd_closedir(filectx.dirp);
|
filectx.dirp = osd::directory::open((const char *)filectx.curdir);
|
||||||
filectx.dirp = osd_opendir((const char *)filectx.curdir);
|
|
||||||
case kFileCmdGetNextListing:
|
case kFileCmdGetNextListing:
|
||||||
if (filectx.dirp) {
|
if (filectx.dirp) {
|
||||||
dp = osd_readdir(filectx.dirp);
|
dp = filectx.dirp->read();
|
||||||
if(dp) {
|
if(dp) {
|
||||||
strncpy((char*)filectx.filename, dp->name, sizeof(filectx.filename));
|
strncpy((char*)filectx.filename, dp->name, sizeof(filectx.filename));
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ struct nbfilectx {
|
|||||||
UINT32 curcmd;
|
UINT32 curcmd;
|
||||||
UINT8 filename[128];
|
UINT8 filename[128];
|
||||||
UINT8 curdir[1024];
|
UINT8 curdir[1024];
|
||||||
osd_directory *dirp;
|
osd::directory::ptr dirp;
|
||||||
osd_file::ptr fd;
|
osd_file::ptr fd;
|
||||||
UINT64 filelen;
|
UINT64 filelen;
|
||||||
UINT32 bytecount;
|
UINT32 bytecount;
|
||||||
|
@ -295,24 +295,23 @@ void device_image_interface::message(const char *format, ...)
|
|||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
bool device_image_interface::try_change_working_directory(const char *subdir)
|
bool device_image_interface::try_change_working_directory(const char *subdir)
|
||||||
{
|
{
|
||||||
osd_directory *directory;
|
const osd::directory::entry *entry;
|
||||||
const osd_directory_entry *entry;
|
bool success = false;
|
||||||
bool success = FALSE;
|
bool done = false;
|
||||||
bool done = FALSE;
|
|
||||||
|
|
||||||
directory = osd_opendir(m_working_directory.c_str());
|
auto directory = osd::directory::open(m_working_directory.c_str());
|
||||||
if (directory != nullptr)
|
if (directory)
|
||||||
{
|
{
|
||||||
while(!done && (entry = osd_readdir(directory)) != nullptr)
|
while (!done && (entry = directory->read()) != nullptr)
|
||||||
{
|
{
|
||||||
if (!core_stricmp(subdir, entry->name))
|
if (!core_stricmp(subdir, entry->name))
|
||||||
{
|
{
|
||||||
done = TRUE;
|
done = true;
|
||||||
success = entry->type == ENTTYPE_DIR;
|
success = entry->type == osd::directory::entry::entry_type::DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osd_closedir(directory);
|
directory.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* did we successfully identify the directory? */
|
/* did we successfully identify the directory? */
|
||||||
|
@ -89,9 +89,6 @@ file_enumerator::file_enumerator(const char *searchpath)
|
|||||||
|
|
||||||
file_enumerator::~file_enumerator()
|
file_enumerator::~file_enumerator()
|
||||||
{
|
{
|
||||||
// close anything open
|
|
||||||
if (m_curdir != nullptr)
|
|
||||||
osd_closedir(m_curdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,30 +97,29 @@ file_enumerator::~file_enumerator()
|
|||||||
// in the search path
|
// in the search path
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
const osd_directory_entry *file_enumerator::next()
|
const osd::directory::entry *file_enumerator::next()
|
||||||
{
|
{
|
||||||
// loop over potentially empty directories
|
// loop over potentially empty directories
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
// if no open directory, get the next path
|
// if no open directory, get the next path
|
||||||
while (m_curdir == nullptr)
|
while (!m_curdir)
|
||||||
{
|
{
|
||||||
// if we fail to get anything more, we're done
|
// if we fail to get anything more, we're done
|
||||||
if (!m_iterator.next(m_pathbuffer))
|
if (!m_iterator.next(m_pathbuffer))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// open the path
|
// open the path
|
||||||
m_curdir = osd_opendir(m_pathbuffer.c_str());
|
m_curdir = osd::directory::open(m_pathbuffer.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the next entry from the current directory
|
// get the next entry from the current directory
|
||||||
const osd_directory_entry *result = osd_readdir(m_curdir);
|
const osd::directory::entry *result = m_curdir->read();
|
||||||
if (result != nullptr)
|
if (result != nullptr)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// we're done; close this directory
|
// we're done; close this directory
|
||||||
osd_closedir(m_curdir);
|
m_curdir.reset();
|
||||||
m_curdir = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,12 +63,12 @@ public:
|
|||||||
~file_enumerator();
|
~file_enumerator();
|
||||||
|
|
||||||
// iterator
|
// iterator
|
||||||
const osd_directory_entry *next();
|
const osd::directory::entry *next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal state
|
// internal state
|
||||||
path_iterator m_iterator;
|
path_iterator m_iterator;
|
||||||
osd_directory * m_curdir;
|
osd::directory::ptr m_curdir;
|
||||||
std::string m_pathbuffer;
|
std::string m_pathbuffer;
|
||||||
//int m_buflen;
|
//int m_buflen;
|
||||||
};
|
};
|
||||||
|
@ -568,7 +568,7 @@ void running_machine::set_saveload_filename(const char *filename)
|
|||||||
// take into account the statename option
|
// take into account the statename option
|
||||||
const char *stateopt = options().state_name();
|
const char *stateopt = options().state_name();
|
||||||
std::string statename = get_statename(stateopt);
|
std::string statename = get_statename(stateopt);
|
||||||
m_saveload_pending_file.assign(statename.c_str()).append(PATH_SEPARATOR).append(filename).append(".sta");
|
m_saveload_pending_file = string_format("%s%s%s.sta", statename, PATH_SEPARATOR, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ void running_machine::handle_saveload()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATERR_INVALID_HEADER:
|
case STATERR_INVALID_HEADER:
|
||||||
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this game.", opname);
|
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this machine.", opname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATERR_READ_ERROR:
|
case STATERR_READ_ERROR:
|
||||||
@ -857,7 +857,7 @@ void running_machine::handle_saveload()
|
|||||||
|
|
||||||
case STATERR_NONE:
|
case STATERR_NONE:
|
||||||
if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
|
if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
|
||||||
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this game.", opnamed);
|
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this machine.", opnamed);
|
||||||
else
|
else
|
||||||
popmessage("State successfully %s.", opnamed);
|
popmessage("State successfully %s.", opnamed);
|
||||||
break;
|
break;
|
||||||
|
@ -1810,19 +1810,19 @@ media_identifier::media_identifier(emu_options &options)
|
|||||||
void media_identifier::identify(const char *filename)
|
void media_identifier::identify(const char *filename)
|
||||||
{
|
{
|
||||||
// first try to open as a directory
|
// first try to open as a directory
|
||||||
osd_directory *directory = osd_opendir(filename);
|
osd::directory::ptr directory = osd::directory::open(filename);
|
||||||
if (directory != nullptr)
|
if (directory)
|
||||||
{
|
{
|
||||||
// iterate over all files in the directory
|
// iterate over all files in the directory
|
||||||
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
|
for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read())
|
||||||
if (entry->type == ENTTYPE_FILE)
|
if (entry->type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
std::string curfile = std::string(filename).append(PATH_SEPARATOR).append(entry->name);
|
std::string curfile = std::string(filename).append(PATH_SEPARATOR).append(entry->name);
|
||||||
identify(curfile.c_str());
|
identify(curfile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// close the directory and be done
|
// close the directory and be done
|
||||||
osd_closedir(directory);
|
directory.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if that failed, and the filename ends with .zip, identify as a ZIP file
|
// if that failed, and the filename ends with .zip, identify as a ZIP file
|
||||||
|
@ -39,13 +39,13 @@ plugin_options::plugin_options()
|
|||||||
void plugin_options::parse_json(std::string path)
|
void plugin_options::parse_json(std::string path)
|
||||||
{
|
{
|
||||||
// first try to open as a directory
|
// first try to open as a directory
|
||||||
osd_directory *directory = osd_opendir(path.c_str());
|
osd::directory::ptr directory = osd::directory::open(path);
|
||||||
if (directory != nullptr)
|
if (directory)
|
||||||
{
|
{
|
||||||
// iterate over all files in the directory
|
// iterate over all files in the directory
|
||||||
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
|
for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read())
|
||||||
{
|
{
|
||||||
if (entry->type == ENTTYPE_FILE)
|
if (entry->type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
std::string name = entry->name;
|
std::string name = entry->name;
|
||||||
if (name == "plugin.json")
|
if (name == "plugin.json")
|
||||||
@ -80,7 +80,7 @@ void plugin_options::parse_json(std::string path)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entry->type == ENTTYPE_DIR)
|
else if (entry->type == osd::directory::entry::entry_type::DIR)
|
||||||
{
|
{
|
||||||
std::string name = entry->name;
|
std::string name = entry->name;
|
||||||
if (!(name == "." || name == ".."))
|
if (!(name == "." || name == ".."))
|
||||||
@ -89,8 +89,5 @@ void plugin_options::parse_json(std::string path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// close the directory and be done
|
|
||||||
osd_closedir(directory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,10 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container
|
|||||||
// load languages
|
// load languages
|
||||||
file_enumerator path(mui.machine().options().language_path());
|
file_enumerator path(mui.machine().options().language_path());
|
||||||
auto lang = mui.machine().options().language();
|
auto lang = mui.machine().options().language();
|
||||||
const osd_directory_entry *dirent;
|
const osd::directory::entry *dirent;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
while ((dirent = path.next()) != nullptr)
|
while ((dirent = path.next()) != nullptr)
|
||||||
if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0)
|
if (dirent->type == osd::directory::entry::entry_type::DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0)
|
||||||
{
|
{
|
||||||
auto name = std::string(dirent->name);
|
auto name = std::string(dirent->name);
|
||||||
auto i = strreplace(name, "_", " (");
|
auto i = strreplace(name, "_", " (");
|
||||||
|
@ -466,7 +466,7 @@ void menu_add_change_folder::populate()
|
|||||||
// open a path
|
// open a path
|
||||||
const char *volume_name = nullptr;
|
const char *volume_name = nullptr;
|
||||||
file_enumerator path(m_current_path.c_str());
|
file_enumerator path(m_current_path.c_str());
|
||||||
const osd_directory_entry *dirent;
|
const osd::directory::entry *dirent;
|
||||||
int folders_count = 0;
|
int folders_count = 0;
|
||||||
|
|
||||||
// add the drives
|
// add the drives
|
||||||
@ -476,7 +476,7 @@ void menu_add_change_folder::populate()
|
|||||||
// add the directories
|
// add the directories
|
||||||
while ((dirent = path.next()) != nullptr)
|
while ((dirent = path.next()) != nullptr)
|
||||||
{
|
{
|
||||||
if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0)
|
if (dirent->type == osd::directory::entry::entry_type::DIR && strcmp(dirent->name, ".") != 0)
|
||||||
item_append(dirent->name, "[DIR]", 0, (void *)(FPTR)++folders_count);
|
item_append(dirent->name, "[DIR]", 0, (void *)(FPTR)++folders_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ menu_file_selector::file_selector_entry *menu_file_selector::append_entry(
|
|||||||
// a menu item for a file selector entry
|
// a menu item for a file selector entry
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent)
|
menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd::directory::entry *dirent)
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
file_selector_entry_type entry_type;
|
file_selector_entry_type entry_type;
|
||||||
@ -459,11 +459,11 @@ menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry
|
|||||||
|
|
||||||
switch(dirent->type)
|
switch(dirent->type)
|
||||||
{
|
{
|
||||||
case ENTTYPE_FILE:
|
case osd::directory::entry::entry_type::FILE:
|
||||||
entry_type = SELECTOR_ENTRY_TYPE_FILE;
|
entry_type = SELECTOR_ENTRY_TYPE_FILE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTTYPE_DIR:
|
case osd::directory::entry::entry_type::DIR:
|
||||||
entry_type = SELECTOR_ENTRY_TYPE_DIRECTORY;
|
entry_type = SELECTOR_ENTRY_TYPE_DIRECTORY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ void menu_file_selector::populate()
|
|||||||
{
|
{
|
||||||
util::zippath_directory *directory = nullptr;
|
util::zippath_directory *directory = nullptr;
|
||||||
osd_file::error err;
|
osd_file::error err;
|
||||||
const osd_directory_entry *dirent;
|
const osd::directory::entry *dirent;
|
||||||
const file_selector_entry *entry;
|
const file_selector_entry *entry;
|
||||||
const file_selector_entry *selected_entry = nullptr;
|
const file_selector_entry *selected_entry = nullptr;
|
||||||
int i;
|
int i;
|
||||||
|
@ -107,7 +107,7 @@ private:
|
|||||||
// methods
|
// methods
|
||||||
int compare_entries(const file_selector_entry *e1, const file_selector_entry *e2);
|
int compare_entries(const file_selector_entry *e1, const file_selector_entry *e2);
|
||||||
file_selector_entry *append_entry(file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath);
|
file_selector_entry *append_entry(file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath);
|
||||||
file_selector_entry *append_dirent_entry(const osd_directory_entry *dirent);
|
file_selector_entry *append_dirent_entry(const osd::directory::entry *dirent);
|
||||||
void append_entry_menu_item(const file_selector_entry *entry);
|
void append_entry_menu_item(const file_selector_entry *entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,31 +88,30 @@ menu_control_device_image::~menu_control_device_image()
|
|||||||
void menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
|
void menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
osd_directory_entry *entry;
|
osd::directory::entry::entry_type file_type;
|
||||||
osd_dir_entry_type file_type;
|
|
||||||
|
|
||||||
/* assemble the full path */
|
/* assemble the full path */
|
||||||
util::zippath_combine(path, current_directory.c_str(), current_file.c_str());
|
util::zippath_combine(path, current_directory.c_str(), current_file.c_str());
|
||||||
|
|
||||||
/* does a file or a directory exist at the path */
|
/* does a file or a directory exist at the path */
|
||||||
entry = osd_stat(path.c_str());
|
auto entry = osd_stat(path.c_str());
|
||||||
file_type = (entry != nullptr) ? entry->type : ENTTYPE_NONE;
|
file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
|
||||||
|
|
||||||
switch(file_type)
|
switch(file_type)
|
||||||
{
|
{
|
||||||
case ENTTYPE_NONE:
|
case osd::directory::entry::entry_type::NONE:
|
||||||
/* no file/dir here - always create */
|
/* no file/dir here - always create */
|
||||||
can_create = true;
|
can_create = true;
|
||||||
need_confirm = false;
|
need_confirm = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTTYPE_FILE:
|
case osd::directory::entry::entry_type::FILE:
|
||||||
/* a file exists here - ask for permission from the user */
|
/* a file exists here - ask for permission from the user */
|
||||||
can_create = true;
|
can_create = true;
|
||||||
need_confirm = true;
|
need_confirm = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTTYPE_DIR:
|
case osd::directory::entry::entry_type::DIR:
|
||||||
/* a directory exists here - we can't save over it */
|
/* a directory exists here - we can't save over it */
|
||||||
ui().popup_time(5, "%s", _("Cannot save over directory"));
|
ui().popup_time(5, "%s", _("Cannot save over directory"));
|
||||||
can_create = false;
|
can_create = false;
|
||||||
@ -124,9 +123,6 @@ void menu_control_device_image::test_create(bool &can_create, bool &need_confirm
|
|||||||
need_confirm = false;
|
need_confirm = false;
|
||||||
fatalerror("Unexpected\n");
|
fatalerror("Unexpected\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry != nullptr)
|
|
||||||
osd_free(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ inifile_manager::inifile_manager(running_machine &machine, ui_options &moptions)
|
|||||||
void inifile_manager::directory_scan()
|
void inifile_manager::directory_scan()
|
||||||
{
|
{
|
||||||
file_enumerator path(m_options.extraini_path());
|
file_enumerator path(m_options.extraini_path());
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
|
|
||||||
while ((dir = path.next()) != nullptr)
|
while ((dir = path.next()) != nullptr)
|
||||||
if (core_filename_ends_with(dir->name, ".ini") && parseopen(dir->name))
|
if (core_filename_ends_with(dir->name, ".ini") && parseopen(dir->name))
|
||||||
|
@ -433,7 +433,7 @@ void menu_crosshair::populate()
|
|||||||
|
|
||||||
/* open a path to the crosshairs */
|
/* open a path to the crosshairs */
|
||||||
file_enumerator path(machine().options().crosshair_path());
|
file_enumerator path(machine().options().crosshair_path());
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
/* reset search flags */
|
/* reset search flags */
|
||||||
bool using_default = false;
|
bool using_default = false;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
|
@ -69,7 +69,7 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container *conta
|
|||||||
// check if there are available icons
|
// check if there are available icons
|
||||||
ui_globals::has_icons = false;
|
ui_globals::has_icons = false;
|
||||||
file_enumerator path(moptions.icons_directory());
|
file_enumerator path(moptions.icons_directory());
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
while ((dir = path.next()) != nullptr)
|
while ((dir = path.next()) != nullptr)
|
||||||
{
|
{
|
||||||
std::string src(dir->name);
|
std::string src(dir->name);
|
||||||
@ -644,7 +644,7 @@ void menu_select_game::build_available_list()
|
|||||||
|
|
||||||
// open a path to the ROMs and find them in the array
|
// open a path to the ROMs and find them in the array
|
||||||
file_enumerator path(machine().options().media_path());
|
file_enumerator path(machine().options().media_path());
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
|
|
||||||
// iterate while we get new objects
|
// iterate while we get new objects
|
||||||
while ((dir = path.next()) != nullptr)
|
while ((dir = path.next()) != nullptr)
|
||||||
|
@ -608,7 +608,7 @@ void menu_select_software::build_software_list()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string searchstr, curpath;
|
std::string searchstr, curpath;
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
for (auto & elem : m_filter.swlist.name)
|
for (auto & elem : m_filter.swlist.name)
|
||||||
{
|
{
|
||||||
path_iterator path(machine().options().media_path());
|
path_iterator path(machine().options().media_path());
|
||||||
@ -621,9 +621,9 @@ void menu_select_software::build_software_list()
|
|||||||
while ((dir = fpath.next()) != nullptr)
|
while ((dir = fpath.next()) != nullptr)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
if (dir->type == ENTTYPE_FILE)
|
if (dir->type == osd::directory::entry::entry_type::FILE)
|
||||||
name = core_filename_extract_base(dir->name, true);
|
name = core_filename_extract_base(dir->name, true);
|
||||||
else if (dir->type == ENTTYPE_DIR && strcmp(dir->name, ".") != 0)
|
else if (dir->type == osd::directory::entry::entry_type::DIR && strcmp(dir->name, ".") != 0)
|
||||||
name = dir->name;
|
name = dir->name;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
@ -63,7 +63,7 @@ void simple_menu_select_game::build_driver_list()
|
|||||||
|
|
||||||
// open a path to the ROMs and find them in the array
|
// open a path to the ROMs and find them in the array
|
||||||
file_enumerator path(machine().options().media_path());
|
file_enumerator path(machine().options().media_path());
|
||||||
const osd_directory_entry *dir;
|
const osd::directory::entry *dir;
|
||||||
|
|
||||||
// iterate while we get new objects
|
// iterate while we get new objects
|
||||||
while ((dir = path.next()) != nullptr)
|
while ((dir = path.next()) != nullptr)
|
||||||
|
@ -1209,6 +1209,30 @@ void mame_ui_manager::draw_profiler(render_container *container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// start_save_state
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void mame_ui_manager::start_save_state()
|
||||||
|
{
|
||||||
|
machine().pause();
|
||||||
|
m_load_save_hold = true;
|
||||||
|
set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_SAVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// start_load_state
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void mame_ui_manager::start_load_state()
|
||||||
|
{
|
||||||
|
machine().pause();
|
||||||
|
m_load_save_hold = true;
|
||||||
|
set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_LOAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// image_handler_ingame - execute display
|
// image_handler_ingame - execute display
|
||||||
// callback function for each image device
|
// callback function for each image device
|
||||||
@ -1386,18 +1410,14 @@ UINT32 mame_ui_manager::handler_ingame(render_container *container)
|
|||||||
// handle a save state request
|
// handle a save state request
|
||||||
if (machine().ui_input().pressed(IPT_UI_SAVE_STATE))
|
if (machine().ui_input().pressed(IPT_UI_SAVE_STATE))
|
||||||
{
|
{
|
||||||
machine().pause();
|
start_save_state();
|
||||||
m_load_save_hold = true;
|
|
||||||
set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_SAVE);
|
|
||||||
return LOADSAVE_SAVE;
|
return LOADSAVE_SAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle a load state request
|
// handle a load state request
|
||||||
if (machine().ui_input().pressed(IPT_UI_LOAD_STATE))
|
if (machine().ui_input().pressed(IPT_UI_LOAD_STATE))
|
||||||
{
|
{
|
||||||
machine().pause();
|
start_load_state();
|
||||||
m_load_save_hold = true;
|
|
||||||
set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_LOAD);
|
|
||||||
return LOADSAVE_LOAD;
|
return LOADSAVE_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,8 @@ public:
|
|||||||
void draw_timecode_counter(render_container *container);
|
void draw_timecode_counter(render_container *container);
|
||||||
void draw_timecode_total(render_container *container);
|
void draw_timecode_total(render_container *container);
|
||||||
void draw_profiler(render_container *container);
|
void draw_profiler(render_container *container);
|
||||||
|
void start_save_state();
|
||||||
|
void start_load_state();
|
||||||
|
|
||||||
// print the game info string into a buffer
|
// print the game info string into a buffer
|
||||||
std::string &game_info_astring(std::string &str);
|
std::string &game_info_astring(std::string &str);
|
||||||
|
@ -37,9 +37,9 @@ class zippath_directory
|
|||||||
public:
|
public:
|
||||||
zippath_directory()
|
zippath_directory()
|
||||||
: returned_parent(false)
|
: returned_parent(false)
|
||||||
, directory(nullptr)
|
, directory()
|
||||||
, called_zip_first(false)
|
, called_zip_first(false)
|
||||||
, zipfile(nullptr)
|
, zipfile()
|
||||||
, returned_dirlist()
|
, returned_dirlist()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -48,11 +48,11 @@ public:
|
|||||||
/** @brief true to returned parent. */
|
/** @brief true to returned parent. */
|
||||||
bool returned_parent;
|
bool returned_parent;
|
||||||
/** @brief The returned entry. */
|
/** @brief The returned entry. */
|
||||||
osd_directory_entry returned_entry;
|
osd::directory::entry returned_entry;
|
||||||
|
|
||||||
/* specific to normal directories */
|
/* specific to normal directories */
|
||||||
/** @brief Pathname of the directory. */
|
/** @brief Pathname of the directory. */
|
||||||
osd_directory *directory;
|
osd::directory::ptr directory;
|
||||||
|
|
||||||
/* specific to ZIP directories */
|
/* specific to ZIP directories */
|
||||||
/** @brief true to called zip first. */
|
/** @brief true to called zip first. */
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
FUNCTION PROTOTYPES
|
FUNCTION PROTOTYPES
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd_dir_entry_type &type);
|
static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd::directory::entry::entry_type &type);
|
||||||
static bool is_zip_file(std::string const &path);
|
static bool is_zip_file(std::string const &path);
|
||||||
static bool is_zip_file_separator(char c);
|
static bool is_zip_file_separator(char c);
|
||||||
static bool is_7z_file(std::string const &path);
|
static bool is_7z_file(std::string const &path);
|
||||||
@ -341,7 +341,7 @@ osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core
|
|||||||
archive_file::error ziperr;
|
archive_file::error ziperr;
|
||||||
archive_file::ptr zip;
|
archive_file::ptr zip;
|
||||||
int header;
|
int header;
|
||||||
osd_dir_entry_type entry_type;
|
osd::directory::entry::entry_type entry_type;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* first, set up the two types of paths */
|
/* first, set up the two types of paths */
|
||||||
@ -616,7 +616,7 @@ static char next_path_char(std::string const &s, std::string::size_type &pos)
|
|||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static const zip_file_header *zippath_find_sub_path(archive_file *zipfile, const char *subpath, osd_dir_entry_type *type)
|
* @fn static const zip_file_header *zippath_find_sub_path(archive_file *zipfile, const char *subpath, osd::directory::entry::entry_type *type)
|
||||||
*
|
*
|
||||||
* @brief Zippath find sub path.
|
* @brief Zippath find sub path.
|
||||||
*
|
*
|
||||||
@ -627,7 +627,7 @@ static char next_path_char(std::string const &s, std::string::size_type &pos)
|
|||||||
* @return null if it fails, else a zip_file_header*.
|
* @return null if it fails, else a zip_file_header*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd_dir_entry_type &type)
|
static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd::directory::entry::entry_type &type)
|
||||||
{
|
{
|
||||||
for (int header = zipfile.first_file(); header >= 0; header = zipfile.next_file())
|
for (int header = zipfile.first_file(); header >= 0; header = zipfile.next_file())
|
||||||
{
|
{
|
||||||
@ -644,18 +644,18 @@ static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpa
|
|||||||
{
|
{
|
||||||
if (!c1)
|
if (!c1)
|
||||||
{
|
{
|
||||||
type = zipfile.current_is_directory() ? ENTTYPE_DIR : ENTTYPE_FILE;
|
type = zipfile.current_is_directory() ? osd::directory::entry::entry_type::DIR : osd::directory::entry::entry_type::FILE;
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
else if ((c1 == '/') || (i <= 1U))
|
else if ((c1 == '/') || (i <= 1U))
|
||||||
{
|
{
|
||||||
type = ENTTYPE_DIR;
|
type = osd::directory::entry::entry_type::DIR;
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type = ENTTYPE_NONE;
|
type = osd::directory::entry::entry_type::NONE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +667,7 @@ static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpa
|
|||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, archive_file *&zipfile, std::string &newpath)
|
* @fn static osd_file::error zippath_resolve(const char *path, osd::directory::entry::entry_type &entry_type, archive_file *&zipfile, std::string &newpath)
|
||||||
*
|
*
|
||||||
* @brief Zippath resolve.
|
* @brief Zippath resolve.
|
||||||
*
|
*
|
||||||
@ -679,17 +679,17 @@ static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpa
|
|||||||
* @return A osd_file::error.
|
* @return A osd_file::error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, archive_file::ptr &zipfile, std::string &newpath)
|
static osd_file::error zippath_resolve(const char *path, osd::directory::entry::entry_type &entry_type, archive_file::ptr &zipfile, std::string &newpath)
|
||||||
{
|
{
|
||||||
newpath.clear();
|
newpath.clear();
|
||||||
|
|
||||||
// be conservative
|
// be conservative
|
||||||
entry_type = ENTTYPE_NONE;
|
entry_type = osd::directory::entry::entry_type::NONE;
|
||||||
zipfile.reset();
|
zipfile.reset();
|
||||||
|
|
||||||
std::string apath(path);
|
std::string apath(path);
|
||||||
std::string apath_trimmed;
|
std::string apath_trimmed;
|
||||||
osd_dir_entry_type current_entry_type;
|
osd::directory::entry::entry_type current_entry_type;
|
||||||
bool went_up = false;
|
bool went_up = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -701,7 +701,7 @@ static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &ent
|
|||||||
apath_trimmed = apath;
|
apath_trimmed = apath;
|
||||||
|
|
||||||
// stat the path
|
// stat the path
|
||||||
std::unique_ptr<osd_directory_entry, void (*)(void *)> current_entry(osd_stat(apath_trimmed), &osd_free);
|
auto current_entry = osd_stat(apath_trimmed);
|
||||||
|
|
||||||
// did we find anything?
|
// did we find anything?
|
||||||
if (current_entry)
|
if (current_entry)
|
||||||
@ -712,20 +712,20 @@ static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &ent
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if we have not found the file or directory, go up
|
// if we have not found the file or directory, go up
|
||||||
current_entry_type = ENTTYPE_NONE;
|
current_entry_type = osd::directory::entry::entry_type::NONE;
|
||||||
went_up = true;
|
went_up = true;
|
||||||
std::string parent;
|
std::string parent;
|
||||||
apath = zippath_parent(parent, apath.c_str());
|
apath = zippath_parent(parent, apath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((current_entry_type == ENTTYPE_NONE) && !is_root(apath.c_str()));
|
while ((current_entry_type == osd::directory::entry::entry_type::NONE) && !is_root(apath.c_str()));
|
||||||
|
|
||||||
// if we did not find anything, then error out
|
// if we did not find anything, then error out
|
||||||
if (current_entry_type == ENTTYPE_NONE)
|
if (current_entry_type == osd::directory::entry::entry_type::NONE)
|
||||||
return osd_file::error::NOT_FOUND;
|
return osd_file::error::NOT_FOUND;
|
||||||
|
|
||||||
// is this file a ZIP file?
|
// is this file a ZIP file?
|
||||||
if ((current_entry_type == ENTTYPE_FILE) &&
|
if ((current_entry_type == osd::directory::entry::entry_type::FILE) &&
|
||||||
((is_zip_file(apath_trimmed) && (archive_file::open_zip(apath_trimmed, zipfile) == archive_file::error::NONE)) ||
|
((is_zip_file(apath_trimmed) && (archive_file::open_zip(apath_trimmed, zipfile) == archive_file::error::NONE)) ||
|
||||||
(is_7z_file(apath_trimmed) && (archive_file::open_7z(apath_trimmed, zipfile) == archive_file::error::NONE))))
|
(is_7z_file(apath_trimmed) && (archive_file::open_7z(apath_trimmed, zipfile) == archive_file::error::NONE))))
|
||||||
{
|
{
|
||||||
@ -736,7 +736,7 @@ static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &ent
|
|||||||
|
|
||||||
// this was a true ZIP path - attempt to identify the type of path
|
// this was a true ZIP path - attempt to identify the type of path
|
||||||
zippath_find_sub_path(*zipfile, newpath, current_entry_type);
|
zippath_find_sub_path(*zipfile, newpath, current_entry_type);
|
||||||
if (current_entry_type == ENTTYPE_NONE)
|
if (current_entry_type == osd::directory::entry::entry_type::NONE)
|
||||||
return osd_file::error::NOT_FOUND;
|
return osd_file::error::NOT_FOUND;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -785,13 +785,13 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* resolve the path */
|
/* resolve the path */
|
||||||
osd_dir_entry_type entry_type;
|
osd::directory::entry::entry_type entry_type;
|
||||||
err = zippath_resolve(path, entry_type, result->zipfile, result->zipprefix);
|
err = zippath_resolve(path, entry_type, result->zipfile, result->zipprefix);
|
||||||
if (err != osd_file::error::NONE)
|
if (err != osd_file::error::NONE)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* we have to be a directory */
|
/* we have to be a directory */
|
||||||
if (entry_type != ENTTYPE_DIR)
|
if (entry_type != osd::directory::entry::entry_type::DIR)
|
||||||
{
|
{
|
||||||
err = osd_file::error::NOT_FOUND;
|
err = osd_file::error::NOT_FOUND;
|
||||||
goto done;
|
goto done;
|
||||||
@ -801,7 +801,7 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
|||||||
if (!result->zipfile)
|
if (!result->zipfile)
|
||||||
{
|
{
|
||||||
/* a conventional directory */
|
/* a conventional directory */
|
||||||
result->directory = osd_opendir(path);
|
result->directory = osd::directory::open(path);
|
||||||
if (!result->directory)
|
if (!result->directory)
|
||||||
{
|
{
|
||||||
err = osd_file::error::FAILURE;
|
err = osd_file::error::FAILURE;
|
||||||
@ -840,7 +840,7 @@ done:
|
|||||||
void zippath_closedir(zippath_directory *directory)
|
void zippath_closedir(zippath_directory *directory)
|
||||||
{
|
{
|
||||||
if (directory->directory != nullptr)
|
if (directory->directory != nullptr)
|
||||||
osd_closedir(directory->directory);
|
directory->directory.reset();
|
||||||
|
|
||||||
if (directory->zipfile != nullptr)
|
if (directory->zipfile != nullptr)
|
||||||
directory->zipfile.reset();
|
directory->zipfile.reset();
|
||||||
@ -901,18 +901,18 @@ static const char *get_relative_path(zippath_directory const &directory)
|
|||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
* @fn const osd::directory::entry *zippath_readdir(zippath_directory *directory)
|
||||||
*
|
*
|
||||||
* @brief Zippath readdir.
|
* @brief Zippath readdir.
|
||||||
*
|
*
|
||||||
* @param [in,out] directory If non-null, pathname of the directory.
|
* @param [in,out] directory If non-null, pathname of the directory.
|
||||||
*
|
*
|
||||||
* @return null if it fails, else an osd_directory_entry*.
|
* @return null if it fails, else an osd::directory::entry*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
const osd::directory::entry *zippath_readdir(zippath_directory *directory)
|
||||||
{
|
{
|
||||||
const osd_directory_entry *result = nullptr;
|
const osd::directory::entry *result = nullptr;
|
||||||
|
|
||||||
if (!directory->returned_parent)
|
if (!directory->returned_parent)
|
||||||
{
|
{
|
||||||
@ -920,7 +920,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
|||||||
directory->returned_parent = true;
|
directory->returned_parent = true;
|
||||||
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
||||||
directory->returned_entry.name = "..";
|
directory->returned_entry.name = "..";
|
||||||
directory->returned_entry.type = ENTTYPE_DIR;
|
directory->returned_entry.type = osd::directory::entry::entry_type::DIR;
|
||||||
result = &directory->returned_entry;
|
result = &directory->returned_entry;
|
||||||
}
|
}
|
||||||
else if (directory->directory)
|
else if (directory->directory)
|
||||||
@ -928,7 +928,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
|||||||
/* a normal directory read */
|
/* a normal directory read */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = osd_readdir(directory->directory);
|
result = directory->directory->read();
|
||||||
}
|
}
|
||||||
while (result && (!strcmp(result->name, ".") || !strcmp(result->name, "..")));
|
while (result && (!strcmp(result->name, ".") || !strcmp(result->name, "..")));
|
||||||
|
|
||||||
@ -937,7 +937,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
|||||||
{
|
{
|
||||||
/* copy; but change the entry type */
|
/* copy; but change the entry type */
|
||||||
directory->returned_entry = *result;
|
directory->returned_entry = *result;
|
||||||
directory->returned_entry.type = ENTTYPE_DIR;
|
directory->returned_entry.type = osd::directory::entry::entry_type::DIR;
|
||||||
result = &directory->returned_entry;
|
result = &directory->returned_entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -983,7 +983,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
|||||||
/* ...and return it */
|
/* ...and return it */
|
||||||
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
||||||
directory->returned_entry.name = directory->returned_dirlist.front().c_str();
|
directory->returned_entry.name = directory->returned_dirlist.front().c_str();
|
||||||
directory->returned_entry.type = ENTTYPE_DIR;
|
directory->returned_entry.type = osd::directory::entry::entry_type::DIR;
|
||||||
result = &directory->returned_entry;
|
result = &directory->returned_entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -992,7 +992,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
|||||||
/* a real file */
|
/* a real file */
|
||||||
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
memset(&directory->returned_entry, 0, sizeof(directory->returned_entry));
|
||||||
directory->returned_entry.name = relpath;
|
directory->returned_entry.name = relpath;
|
||||||
directory->returned_entry.type = ENTTYPE_FILE;
|
directory->returned_entry.type = osd::directory::entry::entry_type::FILE;
|
||||||
directory->returned_entry.size = directory->zipfile->current_uncompressed_length();
|
directory->returned_entry.size = directory->zipfile->current_uncompressed_length();
|
||||||
result = &directory->returned_entry;
|
result = &directory->returned_entry;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
|||||||
void zippath_closedir(zippath_directory *directory);
|
void zippath_closedir(zippath_directory *directory);
|
||||||
|
|
||||||
/* reads a directory entry */
|
/* reads a directory entry */
|
||||||
const osd_directory_entry *zippath_readdir(zippath_directory *directory);
|
const osd::directory::entry *zippath_readdir(zippath_directory *directory);
|
||||||
|
|
||||||
/* returns TRUE if this path is a ZIP path or FALSE if not */
|
/* returns TRUE if this path is a ZIP path or FALSE if not */
|
||||||
int zippath_is_zip(zippath_directory *directory);
|
int zippath_is_zip(zippath_directory *directory);
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
#include "sound/upd7759.h"
|
#include "sound/upd7759.h"
|
||||||
#include "sound/ay8910.h"
|
#include "sound/ay8910.h"
|
||||||
#include "machine/nvram.h"
|
#include "machine/nvram.h"
|
||||||
|
#include "video/ramdac.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -168,26 +169,6 @@ struct bf_blitter_t
|
|||||||
|
|
||||||
#define LOOPTYPE ( ( blitter.command&0x60 ) >> 5 )
|
#define LOOPTYPE ( ( blitter.command&0x60 ) >> 5 )
|
||||||
|
|
||||||
/*
|
|
||||||
MUSIC Semiconductor TR9C1710 RAMDAC or equivalent
|
|
||||||
*/
|
|
||||||
struct ramdac_t
|
|
||||||
{
|
|
||||||
UINT8 addr_w;
|
|
||||||
UINT8 addr_r;
|
|
||||||
UINT8 mask;
|
|
||||||
|
|
||||||
/* 18-bit colors */
|
|
||||||
UINT8 color_r[3];
|
|
||||||
UINT8 color_w[3];
|
|
||||||
UINT32 table[256];
|
|
||||||
|
|
||||||
/* Access counts */
|
|
||||||
UINT8 count_r;
|
|
||||||
UINT8 count_w;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct fdc_t
|
struct fdc_t
|
||||||
{
|
{
|
||||||
UINT8 MSR;
|
UINT8 MSR;
|
||||||
@ -275,10 +256,7 @@ public:
|
|||||||
UINT8 m_col7bit[256];
|
UINT8 m_col7bit[256];
|
||||||
UINT8 m_col6bit[256];
|
UINT8 m_col6bit[256];
|
||||||
struct bf_blitter_t m_blitter;
|
struct bf_blitter_t m_blitter;
|
||||||
struct ramdac_t m_ramdac;
|
|
||||||
struct fdc_t m_fdc;
|
struct fdc_t m_fdc;
|
||||||
DECLARE_READ8_MEMBER(ramdac_r);
|
|
||||||
DECLARE_WRITE8_MEMBER(ramdac_w);
|
|
||||||
DECLARE_READ8_MEMBER(chipset_r);
|
DECLARE_READ8_MEMBER(chipset_r);
|
||||||
DECLARE_WRITE8_MEMBER(chipset_w);
|
DECLARE_WRITE8_MEMBER(chipset_w);
|
||||||
DECLARE_WRITE8_MEMBER(rombank_w);
|
DECLARE_WRITE8_MEMBER(rombank_w);
|
||||||
@ -759,85 +737,6 @@ void bfcobra_state::RunBlit(address_space &space)
|
|||||||
space.device().execute().spin_until_time(attotime::from_nsec( (1000000000 / Z80_XTAL)*cycles_used * 2 ) );
|
space.device().execute().spin_until_time(attotime::from_nsec( (1000000000 / Z80_XTAL)*cycles_used * 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
READ8_MEMBER(bfcobra_state::ramdac_r)
|
|
||||||
{
|
|
||||||
struct ramdac_t &ramdac = m_ramdac;
|
|
||||||
UINT8 val = 0xff;
|
|
||||||
|
|
||||||
switch (offset & 3)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
UINT8 *count = &ramdac.count_r;
|
|
||||||
|
|
||||||
if (*count == 0)
|
|
||||||
{
|
|
||||||
rgb_t color;
|
|
||||||
color = m_palette->pen_color(ramdac.addr_r);
|
|
||||||
|
|
||||||
ramdac.color_r[0] = color.r();
|
|
||||||
ramdac.color_r[1] = color.g();
|
|
||||||
ramdac.color_r[2] = color.b();
|
|
||||||
}
|
|
||||||
|
|
||||||
val = ramdac.color_r[*count];
|
|
||||||
|
|
||||||
/* 8bpp -> 6bpp */
|
|
||||||
val = ((val & 0xc0) >> 2) | ((val >>2) & 0xf);
|
|
||||||
|
|
||||||
if (++*count == 3)
|
|
||||||
{
|
|
||||||
*count = 0;
|
|
||||||
ramdac.addr_r++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
osd_printf_debug("Unhandled RAMDAC read (PC:%.4x)\n", space.device().safe_pcbase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
WRITE8_MEMBER(bfcobra_state::ramdac_w)
|
|
||||||
{
|
|
||||||
struct ramdac_t &ramdac = m_ramdac;
|
|
||||||
|
|
||||||
switch (offset & 3)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
ramdac.addr_w = data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
data &= 0x3f;
|
|
||||||
ramdac.color_w[ramdac.count_w] = pal6bit(data);
|
|
||||||
if (++ramdac.count_w == 3)
|
|
||||||
{
|
|
||||||
m_palette->set_pen_color(ramdac.addr_w, ramdac.color_w[0], ramdac.color_w[1], ramdac.color_w[2]);
|
|
||||||
ramdac.count_w = 0;
|
|
||||||
ramdac.addr_w++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
ramdac.mask = data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
ramdac.addr_r = data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
|
||||||
Flare One Register Map
|
Flare One Register Map
|
||||||
@ -1340,7 +1239,6 @@ void bfcobra_state::machine_reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_bank_data[0] = 1;
|
m_bank_data[0] = 1;
|
||||||
memset(&m_ramdac, 0, sizeof(m_ramdac));
|
|
||||||
reset_fdc();
|
reset_fdc();
|
||||||
|
|
||||||
m_irq_state = m_blitter_irq = m_vblank_irq = m_acia_irq = 0;
|
m_irq_state = m_blitter_irq = m_vblank_irq = m_acia_irq = 0;
|
||||||
@ -1369,7 +1267,15 @@ ADDRESS_MAP_GLOBAL_MASK(0xff)
|
|||||||
AM_RANGE(0x30, 0x30) AM_READ(fdctrl_r)
|
AM_RANGE(0x30, 0x30) AM_READ(fdctrl_r)
|
||||||
AM_RANGE(0x31, 0x31) AM_READWRITE(fddata_r, fdctrl_w)
|
AM_RANGE(0x31, 0x31) AM_READWRITE(fddata_r, fdctrl_w)
|
||||||
AM_RANGE(0x40, 0x40) AM_WRITE(rombank_w)
|
AM_RANGE(0x40, 0x40) AM_WRITE(rombank_w)
|
||||||
AM_RANGE(0x50, 0x53) AM_READWRITE(ramdac_r, ramdac_w)
|
AM_RANGE(0x50, 0x50) AM_DEVWRITE("ramdac", ramdac_device, index_w)
|
||||||
|
AM_RANGE(0x51, 0x51) AM_DEVREADWRITE("ramdac", ramdac_device, pal_r, pal_w)
|
||||||
|
AM_RANGE(0x52, 0x52) AM_DEVWRITE("ramdac", ramdac_device, mask_w)
|
||||||
|
AM_RANGE(0x53, 0x53) AM_DEVWRITE("ramdac", ramdac_device, index_r_w)
|
||||||
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
|
|
||||||
|
static ADDRESS_MAP_START( ramdac_map, AS_0, 8, bfcobra_state )
|
||||||
|
AM_RANGE(0x000, 0x3ff) AM_DEVREADWRITE("ramdac", ramdac_device, ramdac_pal_r, ramdac_rgb666_w)
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
|
|
||||||
@ -1746,6 +1652,9 @@ static MACHINE_CONFIG_START( bfcobra, bfcobra_state )
|
|||||||
|
|
||||||
MCFG_PALETTE_ADD("palette", 256)
|
MCFG_PALETTE_ADD("palette", 256)
|
||||||
|
|
||||||
|
MCFG_RAMDAC_ADD("ramdac", ramdac_map, "palette") // MUSIC Semiconductor TR9C1710 RAMDAC or equivalent
|
||||||
|
MCFG_RAMDAC_SPLIT_READ(1)
|
||||||
|
|
||||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||||
|
|
||||||
MCFG_SOUND_ADD("aysnd", AY8910, M6809_XTAL)
|
MCFG_SOUND_ADD("aysnd", AY8910, M6809_XTAL)
|
||||||
|
@ -652,6 +652,7 @@ ADDRESS_MAP_END
|
|||||||
static ADDRESS_MAP_START( adsp_program_map, AS_PROGRAM, 32, harddriv_state )
|
static ADDRESS_MAP_START( adsp_program_map, AS_PROGRAM, 32, harddriv_state )
|
||||||
ADDRESS_MAP_UNMAP_HIGH
|
ADDRESS_MAP_UNMAP_HIGH
|
||||||
AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("adsp_pgm_memory")
|
AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("adsp_pgm_memory")
|
||||||
|
AM_RANGE(0x2000, 0x3fff) AM_READNOP // ROM?
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ Compatibility list (as per 26-jun-2013)
|
|||||||
0C04660A: BRA $0C04660A ;tight loops there, NOP-ing this opcode makes to go further, perhaps not supposed to go here in the first place?
|
0C04660A: BRA $0C04660A ;tight loops there, NOP-ing this opcode makes to go further, perhaps not supposed to go here in the first place?
|
||||||
0C046608: NOP
|
0C046608: NOP
|
||||||
|
|
||||||
|
(24-jun-2016)
|
||||||
|
- shangril: swapped mahjong inputs (M -> N, C -> B etc.)
|
||||||
|
|
||||||
TODO (general):
|
TODO (general):
|
||||||
- all games that uses YUV just updates one frame then dies, why?
|
- all games that uses YUV just updates one frame then dies, why?
|
||||||
@ -80,7 +82,6 @@ TODO (game-specific):
|
|||||||
- Ferrari 355 Challenge: dies at the network check;
|
- Ferrari 355 Challenge: dies at the network check;
|
||||||
- Giant Gram 2: no VMU emulation;
|
- Giant Gram 2: no VMU emulation;
|
||||||
- Gun Survivor 2: crashes during game loading;
|
- Gun Survivor 2: crashes during game loading;
|
||||||
- Idol Janshi Suchie-Pai 3: returns "i/o board error" msg in game mode;
|
|
||||||
- Lupin the Shooting: "com. error between Naomi BD and i/o BD" after some secs. of gameplay;
|
- Lupin the Shooting: "com. error between Naomi BD and i/o BD" after some secs. of gameplay;
|
||||||
- Monkey Ball: dies when attempts to load the gameplay;
|
- Monkey Ball: dies when attempts to load the gameplay;
|
||||||
- Oinori-Daimyoujin Matsuri: reports "B. RAM error" in test mode, inputs doesn't seem to work after that point;
|
- Oinori-Daimyoujin Matsuri: reports "B. RAM error" in test mode, inputs doesn't seem to work after that point;
|
||||||
@ -9642,10 +9643,10 @@ GAME( 2003, puyofevp, naomi, naomim1, naomi, naomi_state, naomi, ROT0, "Sega", "
|
|||||||
|
|
||||||
/* 841-xxxxx ("Licensed by Sega" Naomi cart games)*/
|
/* 841-xxxxx ("Licensed by Sega" Naomi cart games)*/
|
||||||
/* 0001 */ GAME( 1999, pstone, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Capcom", "Power Stone", GAME_FLAGS )
|
/* 0001 */ GAME( 1999, pstone, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Capcom", "Power Stone", GAME_FLAGS )
|
||||||
/* 0002 */ GAME( 1999, suchie3, naomi, naomim2, suchie3, naomi_state,naomi_mp,ROT0, "Jaleco", "Idol Janshi Suchie-Pai 3 (JPN)", GAME_FLAGS )
|
/* 0002 */ GAME( 1999, suchie3, naomi, naomim2, suchie3, naomi_state,naomi_mp,ROT0, "Jaleco", "Idol Janshi Suchie-Pai 3 (JPN)", MACHINE_IMPERFECT_GRAPHICS|MACHINE_IMPERFECT_SOUND )
|
||||||
/* 0003 */ GAME( 1999, doa2, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 (Rev A)", GAME_FLAGS )
|
/* 0003 */ GAME( 1999, doa2, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 (Rev A)", GAME_FLAGS )
|
||||||
/* 0003 */ GAME( 2000, doa2m, doa2, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 Millennium", GAME_FLAGS )
|
/* 0003 */ GAME( 2000, doa2m, doa2, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 Millennium", GAME_FLAGS )
|
||||||
/* 0004 */ GAME( 1999, shangril, naomi, naomim2, naomi_mp,naomi_state,naomi_mp,ROT0, "Marvelous Ent.", "Dengen Tenshi Taisen Janshi Shangri-la", GAME_FLAGS )
|
/* 0004 */ GAME( 1999, shangril, naomi, naomim2, naomi_mp,naomi_state,naomi_mp,ROT0, "Marvelous Ent.", "Dengen Tenshi Taisen Janshi Shangri-la (Build 0728)", GAME_FLAGS ) // version taken from service mode
|
||||||
/* 0005 */ GAME( 1999, spawn, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Todd Mc Farlane / Capcom","Spawn In the Demon's Hand (Rev B)", GAME_FLAGS )
|
/* 0005 */ GAME( 1999, spawn, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Todd Mc Farlane / Capcom","Spawn In the Demon's Hand (Rev B)", GAME_FLAGS )
|
||||||
/* 0006 */ GAME( 1999, puyoda, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Compile", "Puyo Puyo Da!", GAME_FLAGS )
|
/* 0006 */ GAME( 1999, puyoda, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Compile", "Puyo Puyo Da!", GAME_FLAGS )
|
||||||
/* 0007-01 */ GAME(2000, mvsc2u, mvsc2, naomim2, naomi, naomi_state, mvsc2, ROT0, "Capcom / Marvel", "Marvel Vs. Capcom 2 New Age of Heroes (USA) (Rev A)", GAME_FLAGS)
|
/* 0007-01 */ GAME(2000, mvsc2u, mvsc2, naomim2, naomi, naomi_state, mvsc2, ROT0, "Capcom / Marvel", "Marvel Vs. Capcom 2 New Age of Heroes (USA) (Rev A)", GAME_FLAGS)
|
||||||
@ -9793,7 +9794,7 @@ GAME( 2003, puyofevp, naomi, naomim1, naomi, naomi_state, naomi, ROT0, "Sega", "
|
|||||||
/* 0019A */ GAME( 2003, ggxxrl, naomigd, naomigd, naomi, naomi_state, ggxxrl, ROT0,"Arc System Works","Guilty Gear XX #Reload (Rev A) (GDL-0019A)", GAME_FLAGS )
|
/* 0019A */ GAME( 2003, ggxxrl, naomigd, naomigd, naomi, naomi_state, ggxxrl, ROT0,"Arc System Works","Guilty Gear XX #Reload (Rev A) (GDL-0019A)", GAME_FLAGS )
|
||||||
/* 0020 */ GAME( 2004, tetkiwam,naomigd, naomigd, naomi, naomi_state, naomigd, ROT0, "Success", "Tetris Kiwamemichi (GDL-0020)", GAME_FLAGS )
|
/* 0020 */ GAME( 2004, tetkiwam,naomigd, naomigd, naomi, naomi_state, naomigd, ROT0, "Success", "Tetris Kiwamemichi (GDL-0020)", GAME_FLAGS )
|
||||||
/* 0021 */ GAME( 2003, shikgam2,naomigd, naomigd, naomi, naomi_state, naomigd, ROT270, "Alfa System", "Shikigami No Shiro II / The Castle of Shikigami II (GDL-0021)", GAME_FLAGS )
|
/* 0021 */ GAME( 2003, shikgam2,naomigd, naomigd, naomi, naomi_state, naomigd, ROT270, "Alfa System", "Shikigami No Shiro II / The Castle of Shikigami II (GDL-0021)", GAME_FLAGS )
|
||||||
/* 0022 */ GAME( 2003, usagiym, naomigd, naomigd, naomi_mp,naomi_state,naomigd_mp,ROT0,"Warashi / Mahjong Kobo / Taito", "Usagi - Yamashiro Mahjong Hen (GDL-0022)", GAME_FLAGS )
|
/* 0022 */ GAME( 2003, usagiym, naomigd, naomigd, naomi_mp,naomi_state,naomigd_mp,ROT0,"Warashi / Mahjong Kobo / Taito", "Usagi - Yamashiro Mahjong Hen (GDL-0022)", MACHINE_IMPERFECT_GRAPHICS|MACHINE_IMPERFECT_SOUND )
|
||||||
// 0023 Border Down (GDL-0023)
|
// 0023 Border Down (GDL-0023)
|
||||||
/* 0023A */ GAME( 2003, bdrdown, naomigd, naomigd, naomi, naomi_state, naomigd, ROT0, "G.Rev", "Border Down (Rev A) (GDL-0023A)", GAME_FLAGS )
|
/* 0023A */ GAME( 2003, bdrdown, naomigd, naomigd, naomi, naomi_state, naomigd, ROT0, "G.Rev", "Border Down (Rev A) (GDL-0023A)", GAME_FLAGS )
|
||||||
/* 0024 */ GAME( 2003, psyvar2, naomigd, naomigd, naomi, naomi_state, naomigd, ROT270, "Success", "Psyvariar 2 - The Will To Fabricate (GDL-0024)", GAME_FLAGS )
|
/* 0024 */ GAME( 2003, psyvar2, naomigd, naomigd, naomi, naomi_state, naomigd, ROT270, "Success", "Psyvariar 2 - The Will To Fabricate (GDL-0024)", GAME_FLAGS )
|
||||||
|
@ -276,7 +276,6 @@ Stephh's notes (based on the games M6502 code and some tests) :
|
|||||||
- music freq (Satan of Saturn and clone)
|
- music freq (Satan of Saturn and clone)
|
||||||
- correct music waveform/volume control
|
- correct music waveform/volume control
|
||||||
- correct ROM names
|
- correct ROM names
|
||||||
- fantasy is German? (the continue text is in German)
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1595,7 +1594,7 @@ GAME( 1981, satansatind,satansat,satansat,satansat, driver_device, 0, ROT90, "bo
|
|||||||
GAME( 1981, vanguard, 0, vanguard, vanguard, driver_device, 0, ROT90, "SNK", "Vanguard (SNK)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, vanguard, 0, vanguard, vanguard, driver_device, 0, ROT90, "SNK", "Vanguard (SNK)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
||||||
GAME( 1981, vanguardc,vanguard, vanguard, vanguard, driver_device, 0, ROT90, "SNK (Centuri license)", "Vanguard (Centuri)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, vanguardc,vanguard, vanguard, vanguard, driver_device, 0, ROT90, "SNK (Centuri license)", "Vanguard (Centuri)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
||||||
GAME( 1981, vanguardj,vanguard, vanguard, vanguard, driver_device, 0, ROT90, "SNK", "Vanguard (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, vanguardj,vanguard, vanguard, vanguard, driver_device, 0, ROT90, "SNK", "Vanguard (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
||||||
GAME( 1981, fantasy, 0, fantasy, fantasy, driver_device, 0, ROT90, "SNK", "Fantasy (World)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, fantasy, 0, fantasy, fantasy, driver_device, 0, ROT90, "SNK", "Fantasy (Germany)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) // bootleg?
|
||||||
GAME( 1981, fantasyu, fantasy, fantasy, fantasyu, driver_device, 0, ROT90, "SNK (Rock-Ola license)", "Fantasy (US)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, fantasyu, fantasy, fantasy, fantasyu, driver_device, 0, ROT90, "SNK (Rock-Ola license)", "Fantasy (US)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
||||||
GAME( 1981, fantasyj, fantasy, fantasy, fantasyu, driver_device, 0, ROT90, "SNK", "Fantasy (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
GAME( 1981, fantasyj, fantasy, fantasy, fantasyu, driver_device, 0, ROT90, "SNK", "Fantasy (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
|
||||||
GAME( 1982, pballoon, 0, pballoon, pballoon, driver_device, 0, ROT90, "SNK", "Pioneer Balloon", MACHINE_SUPPORTS_SAVE )
|
GAME( 1982, pballoon, 0, pballoon, pballoon, driver_device, 0, ROT90, "SNK", "Pioneer Balloon", MACHINE_SUPPORTS_SAVE )
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
#include "seibucop_dma.hxx"
|
#include "seibucop_dma.hxx"
|
||||||
#include "seibucop_cmd.hxx"
|
#include "seibucop_cmd.hxx"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#define seibu_cop_log \
|
#define seibu_cop_log \
|
||||||
if (LOG_Commands) logerror
|
if (LOG_Commands) logerror
|
||||||
|
|
||||||
@ -1169,49 +1171,28 @@ WRITE16_MEMBER( raiden2cop_device::cop_sort_param_w)
|
|||||||
|
|
||||||
WRITE16_MEMBER( raiden2cop_device::cop_sort_dma_trig_w)
|
WRITE16_MEMBER( raiden2cop_device::cop_sort_dma_trig_w)
|
||||||
{
|
{
|
||||||
UINT16 sort_size;
|
struct sort_entry {
|
||||||
|
INT16 sorting_key;
|
||||||
|
UINT16 val;
|
||||||
|
};
|
||||||
|
|
||||||
sort_size = data;
|
std::vector<sort_entry> entries(data);
|
||||||
|
for(int i=0; i<data; i++) {
|
||||||
//printf("%04x %04x %04x %04x\n",cop_sort_ram_addr,cop_sort_lookup,cop_sort_param,data);
|
sort_entry &e = entries[i];
|
||||||
|
e.val = m_host_space->read_word(cop_sort_lookup + 2*i);
|
||||||
{
|
e.sorting_key = m_host_space->read_word(cop_sort_ram_addr + e.val);
|
||||||
int i,j;
|
}
|
||||||
UINT8 xchg_flag;
|
switch(cop_sort_param) {
|
||||||
UINT32 addri,addrj;
|
case 1:
|
||||||
UINT16 vali,valj;
|
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b){ return a.sorting_key > b.sorting_key; });
|
||||||
|
break;
|
||||||
// TODO: use a better algorithm than bubble sort!
|
case 2:
|
||||||
for(i=2;i<sort_size;i+=2)
|
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b){ return a.sorting_key < b.sorting_key; });
|
||||||
{
|
break;
|
||||||
for(j=i-2;j<sort_size;j+=2)
|
|
||||||
{
|
|
||||||
addri = cop_sort_ram_addr + m_host_space->read_word(cop_sort_lookup+i);
|
|
||||||
addrj = cop_sort_ram_addr + m_host_space->read_word(cop_sort_lookup+j);
|
|
||||||
|
|
||||||
vali = m_host_space->read_word(addri);
|
|
||||||
valj = m_host_space->read_word(addrj);
|
|
||||||
|
|
||||||
//printf("%08x %08x %04x %04x\n",addri,addrj,vali,valj);
|
|
||||||
|
|
||||||
switch(cop_sort_param)
|
|
||||||
{
|
|
||||||
case 2: xchg_flag = (vali > valj); break;
|
|
||||||
case 1: xchg_flag = (vali < valj); break;
|
|
||||||
default: xchg_flag = 0; /* printf("Warning: sort-DMA used with param %02x\n",cop_sort_param); */ break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(xchg_flag)
|
for(int i=0; i<data; i++)
|
||||||
{
|
m_host_space->write_word(cop_sort_lookup + 2*i, entries[i].val);
|
||||||
UINT16 xch_val;
|
|
||||||
|
|
||||||
xch_val = m_host_space->read_word(cop_sort_lookup+i);
|
|
||||||
m_host_space->write_word(cop_sort_lookup+i,m_host_space->read_word(cop_sort_lookup+j));
|
|
||||||
m_host_space->write_word(cop_sort_lookup+j,xch_val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Random number generators (only verified on 68k games) */
|
/* Random number generators (only verified on 68k games) */
|
||||||
|
293
src/osd/modules/file/posixdir.cpp
Normal file
293
src/osd/modules/file/posixdir.cpp
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Olivier Galibert, R. Belmont, Vas Crabb
|
||||||
|
//============================================================
|
||||||
|
//
|
||||||
|
// sdldir.c - SDL core directory access functions
|
||||||
|
//
|
||||||
|
// SDLMAME by Olivier Galibert and R. Belmont
|
||||||
|
//
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#ifndef __USE_LARGEFILE64
|
||||||
|
#define __USE_LARGEFILE64
|
||||||
|
#endif
|
||||||
|
#ifndef __USE_BSD
|
||||||
|
#define __USE_BSD
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__bsdi__) && !defined(__DragonFly__)
|
||||||
|
#ifdef _XOPEN_SOURCE
|
||||||
|
#if _XOPEN_SOURCE < 500
|
||||||
|
#undef _XOPEN_SOURCE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef _XOPEN_SOURCE
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef _POSIX_C_SOURCE // to get DT_xxx on OS X
|
||||||
|
|
||||||
|
|
||||||
|
#include "osdcore.h"
|
||||||
|
#include "modules/lib/osdlib.h"
|
||||||
|
#include "util/strformat.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace osd {
|
||||||
|
namespace {
|
||||||
|
//============================================================
|
||||||
|
// CONSTANTS
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
constexpr char PATHSEPCH = '\\';
|
||||||
|
constexpr char INVPATHSEPCH = '/';
|
||||||
|
#else
|
||||||
|
constexpr char PATHSEPCH = '/';
|
||||||
|
constexpr char INVPATHSEPCH = '\\';
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) || defined(__ANDROID__) || defined(WIN32) || defined(SDLMAME_NO64BITIO)
|
||||||
|
using sdl_dirent = struct dirent;
|
||||||
|
using sdl_stat = struct stat;
|
||||||
|
#define sdl_readdir readdir
|
||||||
|
#define sdl_stat_fn stat
|
||||||
|
#else
|
||||||
|
using sdl_dirent = struct dirent64;
|
||||||
|
using sdl_stat = struct stat64;
|
||||||
|
#define sdl_readdir readdir64
|
||||||
|
#define sdl_stat_fn stat64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HAS_DT_XXX (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// TYPE DEFINITIONS
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
class posix_directory : public osd::directory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
posix_directory();
|
||||||
|
virtual ~posix_directory() override;
|
||||||
|
|
||||||
|
virtual const entry *read() override;
|
||||||
|
|
||||||
|
virtual bool opendir(std::string const &dirname) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef std::unique_ptr<DIR, int (*)(DIR *)> dir_ptr;
|
||||||
|
|
||||||
|
entry m_entry;
|
||||||
|
sdl_dirent *m_data;
|
||||||
|
dir_ptr m_fd;
|
||||||
|
std::string m_path;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// posix_directory::~posix_directory
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
posix_directory::posix_directory()
|
||||||
|
: m_entry()
|
||||||
|
, m_data(nullptr)
|
||||||
|
, m_fd(nullptr, &::closedir)
|
||||||
|
, m_path()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// posix_directory::~posix_directory
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
posix_directory::~posix_directory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// posix_directory::read
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
const osd::directory::entry *posix_directory::read()
|
||||||
|
{
|
||||||
|
m_data = sdl_readdir(m_fd.get());
|
||||||
|
if (!m_data)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
m_entry.name = m_data->d_name;
|
||||||
|
|
||||||
|
sdl_stat st;
|
||||||
|
bool stat_err(0 > sdl_stat_fn(util::string_format("%s%c%s", m_path, PATHSEPCH, m_data->d_name).c_str(), &st));
|
||||||
|
|
||||||
|
#if HAS_DT_XXX
|
||||||
|
switch (m_data->d_type)
|
||||||
|
{
|
||||||
|
case DT_DIR:
|
||||||
|
m_entry.type = entry::entry_type::DIR;
|
||||||
|
break;
|
||||||
|
case DT_REG:
|
||||||
|
m_entry.type = entry::entry_type::FILE;
|
||||||
|
break;
|
||||||
|
case DT_LNK:
|
||||||
|
if (stat_err)
|
||||||
|
m_entry.type = entry::entry_type::OTHER;
|
||||||
|
else if (S_ISDIR(st.st_mode))
|
||||||
|
m_entry.type = entry::entry_type::DIR;
|
||||||
|
else
|
||||||
|
m_entry.type = entry::entry_type::FILE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_entry.type = entry::entry_type::OTHER;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (stat_err)
|
||||||
|
m_entry.type = entry::entry_type::OTHER;
|
||||||
|
else if (S_ISDIR(st.st_mode))
|
||||||
|
m_entry.type = entry::entry_type::DIR;
|
||||||
|
else
|
||||||
|
m_entry.type = entry::entry_type::FILE;
|
||||||
|
#endif
|
||||||
|
m_entry.size = stat_err ? 0 : std::uint64_t(std::make_unsigned_t<decltype(st.st_size)>(st.st_size));
|
||||||
|
m_entry.last_modified = std::chrono::system_clock::from_time_t(st.st_mtime);
|
||||||
|
return &m_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// posix_directory::opendir
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
bool posix_directory::opendir(std::string const &dirname)
|
||||||
|
{
|
||||||
|
assert(!m_fd);
|
||||||
|
|
||||||
|
osd_subst_env(m_path, dirname);
|
||||||
|
m_fd.reset(::opendir(m_path.c_str()));
|
||||||
|
return bool(m_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// osd::directory::open
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
directory::ptr directory::open(std::string const &dirname)
|
||||||
|
{
|
||||||
|
ptr dir;
|
||||||
|
try { dir = std::make_unique<posix_directory>(); }
|
||||||
|
catch (...) { return nullptr; }
|
||||||
|
|
||||||
|
if (!dir->opendir(dirname))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace osd
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// osd_subst_env
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
void osd_subst_env(std::string &dst, std::string const &src)
|
||||||
|
{
|
||||||
|
std::string result, var;
|
||||||
|
auto start = src.begin();
|
||||||
|
|
||||||
|
// a leading tilde expands as $HOME
|
||||||
|
if ((src.end() != start) && ('~' == *start))
|
||||||
|
{
|
||||||
|
char const *const home = std::getenv("HOME");
|
||||||
|
if (home)
|
||||||
|
{
|
||||||
|
++start;
|
||||||
|
if ((src.end() == start) || (osd::PATHSEPCH == *start))
|
||||||
|
result.append(home);
|
||||||
|
else
|
||||||
|
result.push_back('~');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (src.end() != start)
|
||||||
|
{
|
||||||
|
// find $ marking start of environment variable or end of string
|
||||||
|
auto it = start;
|
||||||
|
while ((src.end() != it) && ('$' != *it)) ++it;
|
||||||
|
if (start != it) result.append(start, it);
|
||||||
|
start = it;
|
||||||
|
|
||||||
|
if (src.end() != start)
|
||||||
|
{
|
||||||
|
start = ++it;
|
||||||
|
if ((src.end() != start) && ('{' == *start))
|
||||||
|
{
|
||||||
|
start = ++it;
|
||||||
|
for (++it; (src.end() != it) && ('}' != *it); ++it) { }
|
||||||
|
if (src.end() == it)
|
||||||
|
{
|
||||||
|
result.append("${").append(start, it);
|
||||||
|
start = it;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var.assign(start, it);
|
||||||
|
start = ++it;
|
||||||
|
const char *const exp = std::getenv(var.c_str());
|
||||||
|
if (exp)
|
||||||
|
result.append(exp);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Warning: osd_subst_env variable %s not found.\n", var.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((src.end() != start) && (('_' == *start) || std::isalnum(*start)))
|
||||||
|
{
|
||||||
|
for (++it; (src.end() != it) && (('_' == *it) || std::isalnum(*it)); ++it) { }
|
||||||
|
var.assign(start, it);
|
||||||
|
start = it;
|
||||||
|
const char *const exp = std::getenv(var.c_str());
|
||||||
|
if (exp)
|
||||||
|
result.append(exp);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Warning: osd_subst_env variable %s not found.\n", var.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back('$');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dst = std::move(result);
|
||||||
|
}
|
@ -14,8 +14,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
#ifndef __USE_LARGEFILE64
|
||||||
#define __USE_LARGEFILE64
|
#define __USE_LARGEFILE64
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __USE_BSD
|
||||||
|
#define __USE_BSD
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
@ -337,7 +342,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN
|
|||||||
// osd_stat
|
// osd_stat
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
osd_directory_entry *osd_stat(const std::string &path)
|
std::unique_ptr<osd::directory::entry> osd_stat(const std::string &path)
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__)
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -350,13 +355,18 @@ osd_directory_entry *osd_stat(const std::string &path)
|
|||||||
|
|
||||||
// create an osd_directory_entry; be sure to make sure that the caller can
|
// create an osd_directory_entry; be sure to make sure that the caller can
|
||||||
// free all resources by just freeing the resulting osd_directory_entry
|
// free all resources by just freeing the resulting osd_directory_entry
|
||||||
osd_directory_entry *const result = reinterpret_cast<osd_directory_entry *>(osd_malloc_array(sizeof(osd_directory_entry) + path.length() + 1));
|
osd::directory::entry *result;
|
||||||
|
try { result = reinterpret_cast<osd::directory::entry *>(::operator new(sizeof(*result) + path.length() + 1)); }
|
||||||
|
catch (...) { return nullptr; }
|
||||||
|
new (result) osd::directory::entry;
|
||||||
|
|
||||||
std::strcpy(reinterpret_cast<char *>(result) + sizeof(*result), path.c_str());
|
std::strcpy(reinterpret_cast<char *>(result) + sizeof(*result), path.c_str());
|
||||||
result->name = reinterpret_cast<char *>(result) + sizeof(*result);
|
result->name = reinterpret_cast<char *>(result) + sizeof(*result);
|
||||||
result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
|
result->type = S_ISDIR(st.st_mode) ? osd::directory::entry::entry_type::DIR : osd::directory::entry::entry_type::FILE;
|
||||||
result->size = std::uint64_t(std::make_unsigned_t<decltype(st.st_size)>(st.st_size));
|
result->size = std::uint64_t(std::make_unsigned_t<decltype(st.st_size)>(st.st_size));
|
||||||
|
result->last_modified = std::chrono::system_clock::from_time_t(st.st_mtime);
|
||||||
|
|
||||||
return result;
|
return std::unique_ptr<osd::directory::entry>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
156
src/osd/modules/file/windir.cpp
Normal file
156
src/osd/modules/file/windir.cpp
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Aaron Giles
|
||||||
|
//============================================================
|
||||||
|
//
|
||||||
|
// windir.c - Win32 OSD core directory access functions
|
||||||
|
//
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
// standard windows headers
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
// MAME headers
|
||||||
|
#include "osdcore.h"
|
||||||
|
|
||||||
|
// MAMEOS headers
|
||||||
|
#include "strconv.h"
|
||||||
|
#include "winutil.h"
|
||||||
|
|
||||||
|
// standard C headers
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
|
namespace osd {
|
||||||
|
namespace {
|
||||||
|
//============================================================
|
||||||
|
// TYPE DEFINITIONS
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
class win_directory : public directory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
win_directory();
|
||||||
|
virtual ~win_directory() override;
|
||||||
|
|
||||||
|
virtual const entry *read() override;
|
||||||
|
|
||||||
|
virtual bool opendir(std::string const &dirname) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HANDLE m_find; // handle to the finder
|
||||||
|
bool m_is_first; // true if this is the first entry
|
||||||
|
entry m_entry; // current entry's data
|
||||||
|
WIN32_FIND_DATA m_data; // current raw data
|
||||||
|
};
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// win_directory::win_directory
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
win_directory::win_directory()
|
||||||
|
: m_find(INVALID_HANDLE_VALUE)
|
||||||
|
, m_is_first(true)
|
||||||
|
{
|
||||||
|
std::memset(&m_data, 0, sizeof(m_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// win_directory::~win_directory
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
win_directory::~win_directory()
|
||||||
|
{
|
||||||
|
// free any data associated
|
||||||
|
if (m_entry.name != nullptr)
|
||||||
|
osd_free((void *)m_entry.name);
|
||||||
|
if (m_find != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose(m_find);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// win_directory::read
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
const directory::entry *win_directory::read()
|
||||||
|
{
|
||||||
|
// if we've previously allocated a name, free it now
|
||||||
|
if (m_entry.name != nullptr)
|
||||||
|
{
|
||||||
|
osd_free((void *)m_entry.name);
|
||||||
|
m_entry.name = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this isn't the first file, do a find next
|
||||||
|
if (!m_is_first)
|
||||||
|
{
|
||||||
|
if (!FindNextFile(m_find, &m_data))
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
m_is_first = false;
|
||||||
|
|
||||||
|
// extract the data
|
||||||
|
m_entry.name = utf8_from_tstring(m_data.cFileName);
|
||||||
|
m_entry.type = win_attributes_to_entry_type(m_data.dwFileAttributes);
|
||||||
|
m_entry.size = m_data.nFileSizeLow | (std::uint64_t(m_data.nFileSizeHigh) << 32);
|
||||||
|
m_entry.last_modified = win_time_point_from_filetime(&m_data.ftLastWriteTime);
|
||||||
|
return (m_entry.name != nullptr) ? &m_entry : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// win_directory::opendir
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
bool win_directory::opendir(std::string const &dirname)
|
||||||
|
{
|
||||||
|
assert(m_find == INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
// convert the path to TCHARs
|
||||||
|
std::unique_ptr<TCHAR, void (*)(void *)> const t_dirname(tstring_from_utf8(dirname.c_str()), &osd_free);
|
||||||
|
if (!t_dirname)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// append \*.* to the directory name
|
||||||
|
auto const dirfilter_size = _tcslen(t_dirname.get()) + 5;
|
||||||
|
std::unique_ptr<TCHAR []> dirfilter;
|
||||||
|
try { dirfilter = std::make_unique<TCHAR[]>(dirfilter_size); }
|
||||||
|
catch (...) { return false; }
|
||||||
|
_sntprintf(dirfilter.get(), dirfilter_size, TEXT("%s\\*.*"), t_dirname.get());
|
||||||
|
|
||||||
|
// attempt to find the first file
|
||||||
|
m_find = FindFirstFileEx(dirfilter.get(), FindExInfoStandard, &m_data, FindExSearchNameMatch, nullptr, 0);
|
||||||
|
if (m_find == INVALID_HANDLE_VALUE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// osd::directory::open
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
directory::ptr directory::open(std::string const &dirname)
|
||||||
|
{
|
||||||
|
// allocate memory to hold the osd_tool_directory structure
|
||||||
|
ptr dir;
|
||||||
|
try { dir = std::make_unique<win_directory>(); }
|
||||||
|
catch (...) { return nullptr; }
|
||||||
|
|
||||||
|
if (!dir->opendir(dirname))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namesapce osd
|
@ -354,7 +354,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN
|
|||||||
// osd_stat
|
// osd_stat
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
osd_directory_entry *osd_stat(const std::string &path)
|
std::unique_ptr<osd::directory::entry> osd_stat(const std::string &path)
|
||||||
{
|
{
|
||||||
// convert the path to TCHARs
|
// convert the path to TCHARs
|
||||||
std::unique_ptr<TCHAR, void (*)(void *)> const t_path(tstring_from_utf8(path.c_str()), &osd_free);
|
std::unique_ptr<TCHAR, void (*)(void *)> const t_path(tstring_from_utf8(path.c_str()), &osd_free);
|
||||||
@ -379,17 +379,20 @@ osd_directory_entry *osd_stat(const std::string &path)
|
|||||||
FindClose(find);
|
FindClose(find);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an osd_directory_entry; be sure to make sure that the caller can
|
// create an osd::directory::entry; be sure to make sure that the caller can
|
||||||
// free all resources by just freeing the resulting osd_directory_entry
|
// free all resources by just freeing the resulting osd::directory::entry
|
||||||
osd_directory_entry *const result = (osd_directory_entry *)osd_malloc_array(sizeof(*result) + path.length() + 1);
|
osd::directory::entry *result;
|
||||||
if (!result)
|
try { result = reinterpret_cast<osd::directory::entry *>(::operator new(sizeof(*result) + path.length() + 1)); }
|
||||||
return nullptr;
|
catch (...) { return nullptr; }
|
||||||
|
new (result) osd::directory::entry;
|
||||||
|
|
||||||
strcpy(((char *) result) + sizeof(*result), path.c_str());
|
strcpy(((char *) result) + sizeof(*result), path.c_str());
|
||||||
result->name = ((char *) result) + sizeof(*result);
|
result->name = ((char *) result) + sizeof(*result);
|
||||||
result->type = win_attributes_to_entry_type(find_data.dwFileAttributes);
|
result->type = win_attributes_to_entry_type(find_data.dwFileAttributes);
|
||||||
result->size = find_data.nFileSizeLow | ((UINT64) find_data.nFileSizeHigh << 32);
|
result->size = find_data.nFileSizeLow | ((UINT64) find_data.nFileSizeHigh << 32);
|
||||||
|
result->last_modified = win_time_point_from_filetime(&find_data.ftLastWriteTime);
|
||||||
|
|
||||||
return result;
|
return std::unique_ptr<osd::directory::entry>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,12 +115,12 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
|||||||
directory_path += "/" + file_directory;
|
directory_path += "/" + file_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
osd_directory *directory = osd_opendir(directory_path.c_str());
|
osd::directory::ptr directory = osd::directory::open(directory_path);
|
||||||
if (directory != nullptr)
|
if (directory)
|
||||||
{
|
{
|
||||||
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
|
for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read())
|
||||||
{
|
{
|
||||||
if (entry->type == ENTTYPE_FILE)
|
if (entry->type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
std::string file(entry->name);
|
std::string file(entry->name);
|
||||||
std::string extension(".png");
|
std::string extension(".png");
|
||||||
@ -159,8 +159,6 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osd_closedir(directory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,12 @@ void chain_manager::destroy_unloaded_chains()
|
|||||||
|
|
||||||
void chain_manager::find_available_chains(std::string root, std::string path)
|
void chain_manager::find_available_chains(std::string root, std::string path)
|
||||||
{
|
{
|
||||||
osd_directory *directory = osd_opendir((root + path).c_str());
|
osd::directory::ptr directory = osd::directory::open(root + path);
|
||||||
if (directory != nullptr)
|
if (directory != nullptr)
|
||||||
{
|
{
|
||||||
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
|
for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read())
|
||||||
{
|
{
|
||||||
if (entry->type == ENTTYPE_FILE)
|
if (entry->type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
std::string name(entry->name);
|
std::string name(entry->name);
|
||||||
std::string extension(".json");
|
std::string extension(".json");
|
||||||
@ -114,7 +114,7 @@ void chain_manager::find_available_chains(std::string root, std::string path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entry->type == ENTTYPE_DIR)
|
else if (entry->type == osd::directory::entry::entry_type::DIR)
|
||||||
{
|
{
|
||||||
std::string name = entry->name;
|
std::string name = entry->name;
|
||||||
if (!(name == "." || name == ".."))
|
if (!(name == "." || name == ".."))
|
||||||
@ -128,8 +128,6 @@ void chain_manager::find_available_chains(std::string root, std::string path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osd_closedir(directory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "osdcomm.h"
|
#include "osdcomm.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -297,76 +298,70 @@ int osd_uchar_from_osdchar(UINT32 /* unicode_char */ *uchar, const char *osdchar
|
|||||||
DIRECTORY INTERFACES
|
DIRECTORY INTERFACES
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/* types of directory entries that can be returned */
|
namespace osd
|
||||||
enum osd_dir_entry_type
|
|
||||||
{
|
{
|
||||||
ENTTYPE_NONE,
|
// directory is an opaque type which represents an open directory
|
||||||
ENTTYPE_FILE,
|
class directory
|
||||||
ENTTYPE_DIR,
|
{
|
||||||
ENTTYPE_OTHER
|
public:
|
||||||
|
typedef std::unique_ptr<directory> ptr;
|
||||||
|
|
||||||
|
// osd::directory::entry contains basic information about a file when iterating through
|
||||||
|
// a directory
|
||||||
|
class entry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class entry_type
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
FILE,
|
||||||
|
DIR,
|
||||||
|
OTHER
|
||||||
|
};
|
||||||
|
|
||||||
|
entry() : name(nullptr), type(entry_type::NONE), size(0) {}
|
||||||
|
const char * name; // name of the entry
|
||||||
|
entry_type type; // type of the entry
|
||||||
|
std::uint64_t size; // size of the entry
|
||||||
|
std::chrono::system_clock::time_point last_modified; // last modified time
|
||||||
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// osd::directory::open: open a directory for iteration
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
//
|
||||||
|
// dirname - path to the directory in question
|
||||||
|
//
|
||||||
|
// Return value:
|
||||||
|
//
|
||||||
|
// upon success, this function should return an directory pointer
|
||||||
|
// which contains opaque data necessary to traverse the directory; on
|
||||||
|
// failure, this function should return nullptr
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
static ptr open(std::string const &dirname);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// osd::directory::~directory: close an open directory
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
virtual ~directory() { }
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// osd::directory::read: return information about the next entry in the directory
|
||||||
|
//
|
||||||
|
// Return value:
|
||||||
|
//
|
||||||
|
// a constant pointer to an entry representing the current item
|
||||||
|
// in the directory, or nullptr, indicating that no more entries are
|
||||||
|
// present
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
virtual const entry *read() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool opendir(std::string const &dirname) = 0;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* osd_directory is an opaque type which represents an open directory */
|
|
||||||
struct osd_directory;
|
|
||||||
|
|
||||||
/* osd_directory_entry contains basic information about a file when iterating through */
|
|
||||||
/* a directory */
|
|
||||||
struct osd_directory_entry
|
|
||||||
{
|
|
||||||
const char * name; /* name of the entry */
|
|
||||||
osd_dir_entry_type type; /* type of the entry */
|
|
||||||
UINT64 size; /* size of the entry */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
|
||||||
osd_opendir: open a directory for iteration
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
dirname - path to the directory in question
|
|
||||||
|
|
||||||
Return value:
|
|
||||||
|
|
||||||
upon success, this function should return an osd_directory pointer
|
|
||||||
which contains opaque data necessary to traverse the directory; on
|
|
||||||
failure, this function should return nullptr
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
osd_directory *osd_opendir(const char *dirname);
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
|
||||||
osd_readdir: return information about the next entry in the directory
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
dir - pointer to an osd_directory that was returned from a prior
|
|
||||||
call to osd_opendir
|
|
||||||
|
|
||||||
Return value:
|
|
||||||
|
|
||||||
a constant pointer to an osd_directory_entry representing the current item
|
|
||||||
in the directory, or nullptr, indicating that no more entries are
|
|
||||||
present
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
const osd_directory_entry *osd_readdir(osd_directory *dir);
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
|
||||||
osd_closedir: close an open directory for iteration
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
dir - pointer to an osd_directory that was returned from a prior
|
|
||||||
call to osd_opendir
|
|
||||||
|
|
||||||
Return value:
|
|
||||||
|
|
||||||
frees any allocated memory and resources associated with the open
|
|
||||||
directory
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
void osd_closedir(osd_directory *dir);
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
osd_is_absolute_path: returns whether the specified path is absolute
|
osd_is_absolute_path: returns whether the specified path is absolute
|
||||||
@ -798,12 +793,11 @@ char *osd_get_clipboard_text(void);
|
|||||||
|
|
||||||
Return value:
|
Return value:
|
||||||
|
|
||||||
an allocated pointer to an osd_directory_entry representing
|
an allocated pointer to an osd::directory::entry representing
|
||||||
info on the path; even if the file does not exist.
|
info on the path; even if the file does not exist.
|
||||||
free with osd_free()
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
osd_directory_entry *osd_stat(std::string const &path);
|
std::unique_ptr<osd::directory::entry> osd_stat(std::string const &path);
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
PATH INTERFACES
|
PATH INTERFACES
|
||||||
|
@ -1,316 +0,0 @@
|
|||||||
// license:BSD-3-Clause
|
|
||||||
// copyright-holders:Olivier Galibert, R. Belmont
|
|
||||||
//============================================================
|
|
||||||
//
|
|
||||||
// sdldir.c - SDL core directory access functions
|
|
||||||
//
|
|
||||||
// SDLMAME by Olivier Galibert and R. Belmont
|
|
||||||
//
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
#ifdef SDLMAME_WIN32
|
|
||||||
#include "../windows/windir.cpp"
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef _LARGEFILE64_SOURCE
|
|
||||||
#define _LARGEFILE64_SOURCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SDLMAME_LINUX
|
|
||||||
#define __USE_LARGEFILE64
|
|
||||||
#endif
|
|
||||||
#ifndef SDLMAME_BSD
|
|
||||||
#ifdef _XOPEN_SOURCE
|
|
||||||
#undef _XOPEN_SOURCE
|
|
||||||
#endif
|
|
||||||
#define _XOPEN_SOURCE 500
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
//#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#ifndef __USE_BSD
|
|
||||||
#define __USE_BSD // to get DT_xxx on Linux
|
|
||||||
#endif
|
|
||||||
#undef _POSIX_C_SOURCE // to get DT_xxx on OS X
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#include "osdcore.h"
|
|
||||||
#include "modules/lib/osdlib.h"
|
|
||||||
|
|
||||||
#if defined(SDLMAME_WIN32)
|
|
||||||
#define PATHSEPCH '\\'
|
|
||||||
#define INVPATHSEPCH '/'
|
|
||||||
#else
|
|
||||||
#define PATHSEPCH '/'
|
|
||||||
#define INVPATHSEPCH '\\'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_HAIKU) || defined(SDLMAME_EMSCRIPTEN) || defined(SDLMAME_ANDROID)
|
|
||||||
typedef struct dirent sdl_dirent;
|
|
||||||
typedef struct stat sdl_stat;
|
|
||||||
#define sdl_readdir readdir
|
|
||||||
#define sdl_stat_fn stat
|
|
||||||
#else
|
|
||||||
typedef struct dirent64 sdl_dirent;
|
|
||||||
typedef struct stat64 sdl_stat;
|
|
||||||
#define sdl_readdir readdir64
|
|
||||||
#define sdl_stat_fn stat64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAS_DT_XXX defined(SDLMAME_LINUX) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
|
|
||||||
|
|
||||||
struct osd_directory
|
|
||||||
{
|
|
||||||
osd_directory_entry ent;
|
|
||||||
sdl_dirent *data;
|
|
||||||
DIR *fd;
|
|
||||||
char *path;
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *build_full_path(const char *path, const char *file)
|
|
||||||
{
|
|
||||||
char *ret = (char *) osd_malloc_array(strlen(path)+strlen(file)+2);
|
|
||||||
char *p = ret;
|
|
||||||
|
|
||||||
strcpy(p, path);
|
|
||||||
p += strlen(path);
|
|
||||||
*p++ = PATHSEPCH;
|
|
||||||
strcpy(p, file);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if HAS_DT_XXX
|
|
||||||
static osd_dir_entry_type get_attributes_enttype(int attributes, char *path)
|
|
||||||
{
|
|
||||||
switch ( attributes )
|
|
||||||
{
|
|
||||||
case DT_DIR:
|
|
||||||
return ENTTYPE_DIR;
|
|
||||||
|
|
||||||
case DT_REG:
|
|
||||||
return ENTTYPE_FILE;
|
|
||||||
|
|
||||||
case DT_LNK:
|
|
||||||
{
|
|
||||||
struct stat s;
|
|
||||||
|
|
||||||
if ( stat(path, &s) != 0 )
|
|
||||||
return ENTTYPE_OTHER;
|
|
||||||
else
|
|
||||||
return S_ISDIR(s.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return ENTTYPE_OTHER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
static osd_dir_entry_type get_attributes_stat(const char *file)
|
|
||||||
{
|
|
||||||
sdl_stat st;
|
|
||||||
if(sdl_stat_fn(file, &st))
|
|
||||||
return (osd_dir_entry_type) 0;
|
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode))
|
|
||||||
return ENTTYPE_DIR;
|
|
||||||
else
|
|
||||||
return ENTTYPE_FILE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static UINT64 osd_get_file_size(const char *file)
|
|
||||||
{
|
|
||||||
sdl_stat st;
|
|
||||||
if(sdl_stat_fn(file, &st))
|
|
||||||
return 0;
|
|
||||||
return st.st_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_opendir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
osd_directory *osd_opendir(const char *dirname)
|
|
||||||
{
|
|
||||||
osd_directory *dir = nullptr;
|
|
||||||
char *tmpstr, *envstr;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
dir = (osd_directory *) osd_malloc(sizeof(osd_directory));
|
|
||||||
if (dir)
|
|
||||||
{
|
|
||||||
memset(dir, 0, sizeof(osd_directory));
|
|
||||||
dir->fd = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpstr = (char *) osd_malloc_array(strlen(dirname)+1);
|
|
||||||
strcpy(tmpstr, dirname);
|
|
||||||
|
|
||||||
if (tmpstr[0] == '$')
|
|
||||||
{
|
|
||||||
envstr = (char *) osd_malloc_array(strlen(tmpstr)+1);
|
|
||||||
|
|
||||||
strcpy(envstr, tmpstr);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (envstr[i] != PATHSEPCH && envstr[i] != INVPATHSEPCH && envstr[i] != 0 && envstr[i] != '.')
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
envstr[i] = '\0';
|
|
||||||
|
|
||||||
const char *envval = osd_getenv(&envstr[1]);
|
|
||||||
if (envval != nullptr)
|
|
||||||
{
|
|
||||||
j = strlen(envval) + strlen(tmpstr) + 1;
|
|
||||||
osd_free(tmpstr);
|
|
||||||
tmpstr = (char *) osd_malloc_array(j);
|
|
||||||
|
|
||||||
// start with the value of $HOME
|
|
||||||
strcpy(tmpstr, envval);
|
|
||||||
// replace the null with a path separator again
|
|
||||||
envstr[i] = PATHSEPCH;
|
|
||||||
// append it
|
|
||||||
strcat(tmpstr, &envstr[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Warning: osd_opendir environment variable %s not found.\n", envstr);
|
|
||||||
osd_free(envstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
dir->fd = opendir(tmpstr);
|
|
||||||
dir->path = tmpstr;
|
|
||||||
|
|
||||||
if (dir && (dir->fd == nullptr))
|
|
||||||
{
|
|
||||||
osd_free(dir->path);
|
|
||||||
osd_free(dir);
|
|
||||||
dir = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_readdir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
const osd_directory_entry *osd_readdir(osd_directory *dir)
|
|
||||||
{
|
|
||||||
char *temp;
|
|
||||||
dir->data = sdl_readdir(dir->fd);
|
|
||||||
|
|
||||||
if (dir->data == nullptr)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
dir->ent.name = dir->data->d_name;
|
|
||||||
temp = build_full_path(dir->path, dir->data->d_name);
|
|
||||||
#if HAS_DT_XXX
|
|
||||||
dir->ent.type = get_attributes_enttype(dir->data->d_type, temp);
|
|
||||||
#else
|
|
||||||
dir->ent.type = get_attributes_stat(temp);
|
|
||||||
#endif
|
|
||||||
dir->ent.size = osd_get_file_size(temp);
|
|
||||||
osd_free(temp);
|
|
||||||
return &dir->ent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_closedir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
void osd_closedir(osd_directory *dir)
|
|
||||||
{
|
|
||||||
if (dir->fd != nullptr)
|
|
||||||
closedir(dir->fd);
|
|
||||||
osd_free(dir->path);
|
|
||||||
osd_free(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_subst_env
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
void osd_subst_env(std::string &dst, std::string const &src)
|
|
||||||
{
|
|
||||||
std::string result, var;
|
|
||||||
auto start = src.begin();
|
|
||||||
|
|
||||||
// a leading tilde expands as $HOME
|
|
||||||
if ((src.end() != start) && ('~' == *start))
|
|
||||||
{
|
|
||||||
char const *const home = std::getenv("HOME");
|
|
||||||
if (home)
|
|
||||||
{
|
|
||||||
++start;
|
|
||||||
if ((src.end() == start) || (PATHSEPCH == *start))
|
|
||||||
result.append(home);
|
|
||||||
else
|
|
||||||
result.push_back('~');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (src.end() != start)
|
|
||||||
{
|
|
||||||
// find $ marking start of environment variable or end of string
|
|
||||||
auto it = start;
|
|
||||||
while ((src.end() != it) && ('$' != *it)) ++it;
|
|
||||||
if (start != it) result.append(start, it);
|
|
||||||
start = it;
|
|
||||||
|
|
||||||
if (src.end() != start)
|
|
||||||
{
|
|
||||||
start = ++it;
|
|
||||||
if ((src.end() != start) && ('{' == *start))
|
|
||||||
{
|
|
||||||
start = ++it;
|
|
||||||
for (++it; (src.end() != it) && ('}' != *it); ++it) { }
|
|
||||||
if (src.end() == it)
|
|
||||||
{
|
|
||||||
result.append("${").append(start, it);
|
|
||||||
start = it;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var.assign(start, it);
|
|
||||||
start = ++it;
|
|
||||||
const char *const exp = std::getenv(var.c_str());
|
|
||||||
if (exp)
|
|
||||||
result.append(exp);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Warning: osd_subst_env variable %s not found.\n", var.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((src.end() != start) && (('_' == *start) || std::isalnum(*start)))
|
|
||||||
{
|
|
||||||
for (++it; (src.end() != it) && (('_' == *it) || std::isalnum(*it)); ++it) { }
|
|
||||||
var.assign(start, it);
|
|
||||||
start = it;
|
|
||||||
const char *const exp = std::getenv(var.c_str());
|
|
||||||
if (exp)
|
|
||||||
result.append(exp);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Warning: osd_subst_env variable %s not found.\n", var.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.push_back('$');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dst = std::move(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,136 +0,0 @@
|
|||||||
// license:BSD-3-Clause
|
|
||||||
// copyright-holders:Aaron Giles
|
|
||||||
//============================================================
|
|
||||||
//
|
|
||||||
// windir.c - Win32 OSD core directory access functions
|
|
||||||
//
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
// standard windows headers
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#include <shlwapi.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
// standard C headers
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
// MAME headers
|
|
||||||
#include "osdcore.h"
|
|
||||||
|
|
||||||
// MAMEOS headers
|
|
||||||
#include "strconv.h"
|
|
||||||
#include "winutil.h"
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// TYPE DEFINITIONS
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
struct osd_directory
|
|
||||||
{
|
|
||||||
HANDLE find; // handle to the finder
|
|
||||||
int is_first; // TRUE if this is the first entry
|
|
||||||
osd_directory_entry entry; // current entry's data
|
|
||||||
WIN32_FIND_DATA data; // current raw data
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_opendir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
osd_directory *osd_opendir(const char *dirname)
|
|
||||||
{
|
|
||||||
osd_directory *dir = nullptr;
|
|
||||||
TCHAR *t_dirname = nullptr;
|
|
||||||
TCHAR *dirfilter = nullptr;
|
|
||||||
size_t dirfilter_size;
|
|
||||||
|
|
||||||
// allocate memory to hold the osd_tool_directory structure
|
|
||||||
dir = (osd_directory *)malloc(sizeof(*dir));
|
|
||||||
if (dir == nullptr)
|
|
||||||
goto error;
|
|
||||||
memset(dir, 0, sizeof(*dir));
|
|
||||||
|
|
||||||
// initialize the structure
|
|
||||||
dir->find = INVALID_HANDLE_VALUE;
|
|
||||||
dir->is_first = TRUE;
|
|
||||||
|
|
||||||
// convert the path to TCHARs
|
|
||||||
t_dirname = tstring_from_utf8(dirname);
|
|
||||||
if (t_dirname == nullptr)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
// append \*.* to the directory name
|
|
||||||
dirfilter_size = _tcslen(t_dirname) + 5;
|
|
||||||
dirfilter = (TCHAR *)malloc(dirfilter_size * sizeof(*dirfilter));
|
|
||||||
if (dirfilter == nullptr)
|
|
||||||
goto error;
|
|
||||||
_sntprintf(dirfilter, dirfilter_size, TEXT("%s\\*.*"), t_dirname);
|
|
||||||
|
|
||||||
// attempt to find the first file
|
|
||||||
dir->find = FindFirstFileEx(dirfilter, FindExInfoStandard, &dir->data, FindExSearchNameMatch, nullptr, 0);
|
|
||||||
|
|
||||||
error:
|
|
||||||
// cleanup
|
|
||||||
if (t_dirname != nullptr)
|
|
||||||
osd_free(t_dirname);
|
|
||||||
if (dirfilter != nullptr)
|
|
||||||
free(dirfilter);
|
|
||||||
if (dir != nullptr && dir->find == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
free(dir);
|
|
||||||
dir = nullptr;
|
|
||||||
}
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_readdir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
const osd_directory_entry *osd_readdir(osd_directory *dir)
|
|
||||||
{
|
|
||||||
// if we've previously allocated a name, free it now
|
|
||||||
if (dir->entry.name != nullptr)
|
|
||||||
{
|
|
||||||
osd_free((void *)dir->entry.name);
|
|
||||||
dir->entry.name = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if this isn't the first file, do a find next
|
|
||||||
if (!dir->is_first)
|
|
||||||
{
|
|
||||||
if (!FindNextFile(dir->find, &dir->data))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, just use the data we already had
|
|
||||||
else
|
|
||||||
dir->is_first = FALSE;
|
|
||||||
|
|
||||||
// extract the data
|
|
||||||
dir->entry.name = utf8_from_tstring(dir->data.cFileName);
|
|
||||||
dir->entry.type = win_attributes_to_entry_type(dir->data.dwFileAttributes);
|
|
||||||
dir->entry.size = dir->data.nFileSizeLow | ((UINT64) dir->data.nFileSizeHigh << 32);
|
|
||||||
return (dir->entry.name != nullptr) ? &dir->entry : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// osd_closedir
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
void osd_closedir(osd_directory *dir)
|
|
||||||
{
|
|
||||||
// free any data associated
|
|
||||||
if (dir->entry.name != nullptr)
|
|
||||||
osd_free((void *)dir->entry.name);
|
|
||||||
if (dir->find != INVALID_HANDLE_VALUE)
|
|
||||||
FindClose(dir->find);
|
|
||||||
free(dir);
|
|
||||||
}
|
|
@ -23,14 +23,26 @@
|
|||||||
// win_attributes_to_entry_type
|
// win_attributes_to_entry_type
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
osd_dir_entry_type win_attributes_to_entry_type(DWORD attributes)
|
osd::directory::entry::entry_type win_attributes_to_entry_type(DWORD attributes)
|
||||||
{
|
{
|
||||||
if (attributes == 0xFFFFFFFF)
|
if (attributes == 0xFFFFFFFF)
|
||||||
return ENTTYPE_NONE;
|
return osd::directory::entry::entry_type::NONE;
|
||||||
else if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
else if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return ENTTYPE_DIR;
|
return osd::directory::entry::entry_type::DIR;
|
||||||
else
|
else
|
||||||
return ENTTYPE_FILE;
|
return osd::directory::entry::entry_type::FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// win_time_point_from_filetime
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
std::chrono::system_clock::time_point win_time_point_from_filetime(LPFILETIME file_time)
|
||||||
|
{
|
||||||
|
return std::chrono::system_clock::time_point(std::chrono::system_clock::duration(
|
||||||
|
(static_cast<__int64>(file_time->dwHighDateTime) << 32) | file_time->dwLowDateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
#include "osdcore.h"
|
#include "osdcore.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
// Shared code
|
// Shared code
|
||||||
osd_dir_entry_type win_attributes_to_entry_type(DWORD attributes);
|
osd::directory::entry::entry_type win_attributes_to_entry_type(DWORD attributes);
|
||||||
|
std::chrono::system_clock::time_point win_time_point_from_filetime(LPFILETIME file_time);
|
||||||
BOOL win_is_gui_application(void);
|
BOOL win_is_gui_application(void);
|
||||||
HMODULE WINAPI GetModuleHandleUni();
|
HMODULE WINAPI GetModuleHandleUni();
|
||||||
|
|
||||||
|
@ -448,22 +448,20 @@ static void printname(const fileinfo *file1,const fileinfo *file2,float score,in
|
|||||||
|
|
||||||
static int load_files(int i, int *found, const char *path)
|
static int load_files(int i, int *found, const char *path)
|
||||||
{
|
{
|
||||||
osd_directory *dir;
|
|
||||||
|
|
||||||
/* attempt to open as a directory first */
|
/* attempt to open as a directory first */
|
||||||
dir = osd_opendir(path);
|
auto dir = osd::directory::open(path);
|
||||||
if (dir != nullptr)
|
if (dir)
|
||||||
{
|
{
|
||||||
const osd_directory_entry *d;
|
const osd::directory::entry *d;
|
||||||
|
|
||||||
/* load all files in directory */
|
/* load all files in directory */
|
||||||
while ((d = osd_readdir(dir)) != nullptr)
|
while ((d = dir->read()) != nullptr)
|
||||||
{
|
{
|
||||||
const char *d_name = d->name;
|
const char *d_name = d->name;
|
||||||
char buf[255+1];
|
char buf[255+1];
|
||||||
|
|
||||||
sprintf(buf, "%s%c%s", path, PATH_DELIM, d_name);
|
sprintf(buf, "%s%c%s", path, PATH_DELIM, d_name);
|
||||||
if (d->type == ENTTYPE_FILE)
|
if (d->type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
UINT64 size = d->size;
|
UINT64 size = d->size;
|
||||||
while (size && (size & 1) == 0) size >>= 1;
|
while (size && (size & 1) == 0) size >>= 1;
|
||||||
@ -484,7 +482,7 @@ static int load_files(int i, int *found, const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osd_closedir(dir);
|
dir.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if not, try to open as a ZIP file */
|
/* if not, try to open as a ZIP file */
|
||||||
|
@ -324,7 +324,7 @@ static int compare_list_entries(const void *p1, const void *p2)
|
|||||||
|
|
||||||
static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std::string &dstdir, std::string &tempheader, std::string &tempfooter)
|
static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std::string &dstdir, std::string &tempheader, std::string &tempfooter)
|
||||||
{
|
{
|
||||||
static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
|
static const osd::directory::entry::entry_type typelist[] = { osd::directory::entry::entry_type::DIR, osd::directory::entry::entry_type::FILE };
|
||||||
|
|
||||||
// extract a normalized subpath
|
// extract a normalized subpath
|
||||||
std::string srcdir_subpath;
|
std::string srcdir_subpath;
|
||||||
@ -344,10 +344,10 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std:
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
|
for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
|
||||||
{
|
{
|
||||||
osd_dir_entry_type entry_type = typelist[entindex];
|
auto entry_type = typelist[entindex];
|
||||||
|
|
||||||
// open the directory and iterate through it
|
// open the directory and iterate through it
|
||||||
osd_directory *dir = osd_opendir(srcdir.c_str());
|
auto dir = osd::directory::open(srcdir.c_str());
|
||||||
if (dir == nullptr)
|
if (dir == nullptr)
|
||||||
{
|
{
|
||||||
result = 1;
|
result = 1;
|
||||||
@ -355,10 +355,10 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build up the list of files
|
// build up the list of files
|
||||||
const osd_directory_entry *entry;
|
const osd::directory::entry *entry;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
list_entry *list = nullptr;
|
list_entry *list = nullptr;
|
||||||
while ((entry = osd_readdir(dir)) != nullptr)
|
while ((entry = dir->read()) != nullptr)
|
||||||
if (entry->type == entry_type && entry->name[0] != '.')
|
if (entry->type == entry_type && entry->name[0] != '.')
|
||||||
{
|
{
|
||||||
auto lentry = new list_entry;
|
auto lentry = new list_entry;
|
||||||
@ -369,7 +369,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// close the directory
|
// close the directory
|
||||||
osd_closedir(dir);
|
dir.reset();
|
||||||
|
|
||||||
// skip if nothing found
|
// skip if nothing found
|
||||||
if (found == 0)
|
if (found == 0)
|
||||||
@ -398,7 +398,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std:
|
|||||||
{
|
{
|
||||||
// add a header
|
// add a header
|
||||||
if (curlist == list)
|
if (curlist == list)
|
||||||
indexfile->printf("\t<h2>%s</h2>\n\t<ul>\n", (entry_type == ENTTYPE_DIR) ? "Directories" : "Files");
|
indexfile->printf("\t<h2>%s</h2>\n\t<ul>\n", (entry_type == osd::directory::entry::entry_type::DIR) ? "Directories" : "Files");
|
||||||
|
|
||||||
// build the source filename
|
// build the source filename
|
||||||
std::string srcfile;
|
std::string srcfile;
|
||||||
@ -406,7 +406,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std:
|
|||||||
|
|
||||||
// if we have a file, output it
|
// if we have a file, output it
|
||||||
std::string dstfile;
|
std::string dstfile;
|
||||||
if (entry_type == ENTTYPE_FILE)
|
if (entry_type == osd::directory::entry::entry_type::FILE)
|
||||||
{
|
{
|
||||||
// make sure we care, first
|
// make sure we care, first
|
||||||
file_type type = FILE_TYPE_INVALID;
|
file_type type = FILE_TYPE_INVALID;
|
||||||
|
Loading…
Reference in New Issue
Block a user