MCPcopy Create free account
hub / github.com/GPUOpen-Tools/GPU-Reshape / SanitizePath

Function SanitizePath

Source/Libraries/Common/Source/FileSystem.cpp:158–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158std::string SanitizePath(const std::string_view &view) {
159 std::string path;
160 path.reserve(view.length());
161
162 // Was the last character a delimiter?
163 bool wasDelim = false;
164
165 // Construct new string
166 for (size_t i = 0; i < view.length(); i++) {
167 bool isDelim = IsPathDelim(view[i]);
168
169 // Skip if the last was a delimiter
170 if (wasDelim && isDelim) {
171 continue;
172 }
173
174 // Set state
175 wasDelim = isDelim;
176
177 // Sanitize delims
178 char _char;
179 switch (view[i]) {
180 default:
181 _char = view[i];
182 break;
183 case '/':
184 _char = '\\';
185 break;
186 }
187
188 // Add character
189 path.insert(path.end(), _char);
190 }
191
192 // OK
193 return path;
194}
195
196bool PathExists(const std::string& view) {
197 struct stat buffer;

Callers 2

SanitizeCompilerPathFunction · 0.85
SanitizeCompilerPathFunction · 0.85

Calls 4

IsPathDelimFunction · 0.85
reserveMethod · 0.80
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected