108
void MDFN_GetFilePathComponents(const std::string &file_path, std::string *dir_path_out, std::string *file_base_out, std::string *file_ext_out)
110
size_t final_ds; // in file_path
112
size_t fn_final_dot; // in local var file_name
114
string dir_path, file_base, file_ext;
117
final_ds = file_path.find_last_of(':');
119
final_ds = file_path.find_last_of('/');
121
final_ds = file_path.find_last_of('\\');
125
size_t alt_final_ds = file_path.find_last_of('/');
127
if(final_ds == string::npos || (alt_final_ds != string::npos && alt_final_ds > final_ds))
128
final_ds = alt_final_ds;
133
if(final_ds == string::npos)
135
dir_path = string(".");
136
file_name = file_path;
140
dir_path = file_path.substr(0, final_ds);
141
file_name = file_path.substr(final_ds + 1);
144
fn_final_dot = file_name.find_last_of('.');
146
if(fn_final_dot != string::npos)
148
file_base = file_name.substr(0, fn_final_dot);
149
file_ext = file_name.substr(fn_final_dot);
153
file_base = file_name;
154
file_ext = string("");
158
*dir_path_out = dir_path;
161
*file_base_out = file_base;
164
*file_ext_out = file_ext;
167
std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_path, bool skip_safety_check)
169
if(!skip_safety_check && !MDFN_IsFIROPSafe(rel_path))
170
throw MDFN_Error(0, _("Referenced path \"%s\" is potentially unsafe. See \"filesys.untrusted_fip_check\" setting.\n"), rel_path.c_str());
172
if(IsAbsolutePath(rel_path.c_str()))
176
return(dir_path + std::string(PSS) + rel_path);
106
181
typedef std::map<char, std::string> FSMap;