~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/general.cpp

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-01-31 07:21:35 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120131072135-es3dj12y00xcnrsk
Tags: 0.9.19-1
* New upstream WIP version.
* Update copyright information.
* Refresh use-system-tremor.patch and remove psx-big-endian-only.patch.
* Add spelling-fixes.patch based on Lintian's recommendations.
* Build-depend on debhelper 9 or later and remove corresponding Lintian
  override.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
 if(!MDFN_GetSettingB("filesys.untrusted_fip_check"))
91
91
  return(true);
92
92
 
 
93
 if(path.find('\0') != string::npos)
 
94
  return(false);
 
95
 
93
96
 if(path.find(':') != string::npos)
94
97
  return(false);
95
98
 
102
105
 return(true);
103
106
}
104
107
 
 
108
void MDFN_GetFilePathComponents(const std::string &file_path, std::string *dir_path_out, std::string *file_base_out, std::string *file_ext_out)
 
109
{
 
110
 size_t final_ds;               // in file_path
 
111
 string file_name;
 
112
 size_t fn_final_dot;           // in local var file_name
 
113
 // Temporary output:
 
114
 string dir_path, file_base, file_ext;
 
115
 
 
116
#if PSS_STYLE==4
 
117
 final_ds = file_path.find_last_of(':');
 
118
#elif PSS_STYLE==1
 
119
 final_ds = file_path.find_last_of('/');
 
120
#else
 
121
 final_ds = file_path.find_last_of('\\');
 
122
 
 
123
 #if PSS_STYLE!=3
 
124
  {
 
125
   size_t alt_final_ds = file_path.find_last_of('/');
 
126
 
 
127
   if(final_ds == string::npos || (alt_final_ds != string::npos && alt_final_ds > final_ds))
 
128
    final_ds = alt_final_ds;
 
129
  }
 
130
 #endif
 
131
#endif
 
132
 
 
133
 if(final_ds == string::npos)
 
134
 {
 
135
  dir_path = string(".");
 
136
  file_name = file_path;
 
137
 }
 
138
 else
 
139
 {
 
140
  dir_path = file_path.substr(0, final_ds);
 
141
  file_name = file_path.substr(final_ds + 1);
 
142
 }
 
143
 
 
144
 fn_final_dot = file_name.find_last_of('.');
 
145
 
 
146
 if(fn_final_dot != string::npos)
 
147
 {
 
148
  file_base = file_name.substr(0, fn_final_dot);
 
149
  file_ext = file_name.substr(fn_final_dot);
 
150
 }
 
151
 else
 
152
 {
 
153
  file_base = file_name;
 
154
  file_ext = string("");
 
155
 }
 
156
 
 
157
 if(dir_path_out)
 
158
  *dir_path_out = dir_path;
 
159
 
 
160
 if(file_base_out)
 
161
  *file_base_out = file_base;
 
162
 
 
163
 if(file_ext_out)
 
164
  *file_ext_out = file_ext;
 
165
}
 
166
 
 
167
std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_path, bool skip_safety_check)
 
168
{
 
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());
 
171
 
 
172
 if(IsAbsolutePath(rel_path.c_str()))
 
173
  return(rel_path);
 
174
 else
 
175
 {
 
176
  return(dir_path + std::string(PSS) + rel_path);
 
177
 }
 
178
}
 
179
 
105
180
 
106
181
typedef std::map<char, std::string> FSMap;
107
182