| 2229 | } |
| 2230 | |
| 2231 | static std::string FindFile(const std::vector<std::string> &paths, |
| 2232 | const std::string &filepath, FsCallbacks *fs) { |
| 2233 | if (fs == nullptr || fs->ExpandFilePath == nullptr || |
| 2234 | fs->FileExists == nullptr) { |
| 2235 | // Error, fs callback[s] missing |
| 2236 | return std::string(); |
| 2237 | } |
| 2238 | |
| 2239 | // https://github.com/syoyo/tinygltf/issues/416 |
| 2240 | // Use strlen() since std::string's size/length reports the number of elements |
| 2241 | // in the buffer, not the length of string(null-terminated) strip |
| 2242 | // null-character in the middle of string. |
| 2243 | size_t slength = strlen(filepath.c_str()); |
| 2244 | if (slength == 0) { |
| 2245 | return std::string(); |
| 2246 | } |
| 2247 | |
| 2248 | std::string cleaned_filepath = std::string(filepath.c_str()); |
| 2249 | |
| 2250 | for (size_t i = 0; i < paths.size(); i++) { |
| 2251 | std::string absPath = |
| 2252 | fs->ExpandFilePath(JoinPath(paths[i], cleaned_filepath), fs->user_data); |
| 2253 | if (fs->FileExists(absPath, fs->user_data)) { |
| 2254 | return absPath; |
| 2255 | } |
| 2256 | } |
| 2257 | |
| 2258 | return std::string(); |
| 2259 | } |
| 2260 | |
| 2261 | static std::string GetFilePathExtension(const std::string &FileName) { |
| 2262 | if (FileName.find_last_of(".") != std::string::npos) |
no test coverage detected