mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Create osd_is_valid_filename_char() and osd_is_valid_filepath_char() functions to check to see if a character is legal, and moved retired is_valid_filename_char() in filecreate.cpp. POSIX versions not implemented yet.
This commit is contained in:
parent
4079da505e
commit
2ea76d70ea
@ -135,29 +135,6 @@ void menu_confirm_save_as::handle()
|
||||
FILE CREATE MENU
|
||||
***************************************************************************/
|
||||
|
||||
//-------------------------------------------------
|
||||
// is_valid_filename_char - tests to see if a
|
||||
// character is valid in a filename
|
||||
//-------------------------------------------------
|
||||
|
||||
static int is_valid_filename_char(unicode_char unichar)
|
||||
{
|
||||
// this should really be in the OSD layer, and it shouldn't be 7-bit bullshit
|
||||
static const char valid_filename_char[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00-0f
|
||||
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10-1f
|
||||
1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, // !"#$%&'()*+,-./
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0123456789:;<=>?
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // @ABCDEFGHIJKLMNO
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // PQRSTUVWXYZ[\]^_
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // `abcdefghijklmno
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, // pqrstuvwxyz{|}~
|
||||
};
|
||||
return (unichar < ARRAY_LENGTH(valid_filename_char)) && valid_filename_char[unichar];
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// ctor
|
||||
//-------------------------------------------------
|
||||
@ -271,7 +248,7 @@ void menu_file_create::handle()
|
||||
case IPT_SPECIAL:
|
||||
if (get_selection() == ITEMREF_NEW_IMAGE_NAME)
|
||||
{
|
||||
input_character(m_filename, event->unichar, &is_valid_filename_char);
|
||||
input_character(m_filename, event->unichar, &osd_is_valid_filename_char);
|
||||
reset(reset_options::REMEMBER_POSITION);
|
||||
}
|
||||
break;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "strconv.h"
|
||||
#include "winutil.h"
|
||||
#include "winutf8.h"
|
||||
#include "unicode.h"
|
||||
|
||||
// MAME headers
|
||||
#include "osdcore.h"
|
||||
@ -465,6 +466,38 @@ const char *osd_get_volume_name(int idx)
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_is_valid_filename_char
|
||||
//============================================================
|
||||
|
||||
bool osd_is_valid_filename_char(unicode_char uchar)
|
||||
{
|
||||
return osd_is_valid_filepath_char(uchar)
|
||||
&& uchar != '/'
|
||||
&& uchar != '\\'
|
||||
&& uchar != ':';
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_is_valid_filepath_char
|
||||
//============================================================
|
||||
|
||||
bool osd_is_valid_filepath_char(unicode_char uchar)
|
||||
{
|
||||
return uchar >= 0x20
|
||||
&& uchar != '<'
|
||||
&& uchar != '>'
|
||||
&& uchar != '\"'
|
||||
&& uchar != '|'
|
||||
&& uchar != '?'
|
||||
&& uchar != '*'
|
||||
&& uchar_isvalid(uchar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// win_error_to_file_error
|
||||
//============================================================
|
||||
|
@ -85,6 +85,11 @@ using INT64 = std::int64_t;
|
||||
/* pointer-sized values */
|
||||
using FPTR = uintptr_t;
|
||||
|
||||
/* unicode types */
|
||||
using utf16_char = std::uint16_t;
|
||||
using unicode_char = std::uint32_t;
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -290,9 +290,38 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN
|
||||
|
||||
The number of characters required to form a Unicode character.
|
||||
-----------------------------------------------------------------------------*/
|
||||
int osd_uchar_from_osdchar(UINT32 /* unicode_char */ *uchar, const char *osdchar, size_t count);
|
||||
int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
osd_is_valid_filename_char: is the given character legal for filenames?
|
||||
|
||||
Parameters:
|
||||
|
||||
uchar - the character to check
|
||||
|
||||
Return value:
|
||||
|
||||
Whether this character is legal in a filename
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
bool osd_is_valid_filename_char(unicode_char uchar);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
osd_is_valid_filepath_char: is the given character legal for paths?
|
||||
|
||||
Parameters:
|
||||
|
||||
uchar - the character to check
|
||||
|
||||
Return value:
|
||||
|
||||
Whether this character is legal in a file path
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
bool osd_is_valid_filepath_char(unicode_char uchar);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DIRECTORY INTERFACES
|
||||
|
Loading…
Reference in New Issue
Block a user