// We don't track every file. This function filters potential files. static bool checkInWhitelist(utString path) { // Note the platform-specific version of our whitelisted folders. static utString assetPath = "./assets"; platform_normalizePath(const_cast<char*>(assetPath.c_str())); static utString binPath = "./bin"; platform_normalizePath(const_cast<char*>(binPath.c_str())); static utString srcPath = "./src"; platform_normalizePath(const_cast<char*>(srcPath.c_str())); // Just prefix match against assets for now - ignore things in other folders. lmLogDebug(gAssetAgentLogGroup, "Whitelisting path %s prefix %s\n", path.c_str(), path.substr(0, 6).c_str()); platform_normalizePath(const_cast<char*>(path.c_str())); if (path.substr(path.length() - 3, 3) == "tmp") { return false; } if (path.substr(0, 8) == assetPath) { return true; } if (path.substr(0, 5) == srcPath) { return true; } if (path.substr(0, 5) == binPath) { return true; } return false; }
// Helper to recognize an asset's type from its path/name. static int loom_asset_recognizeAssetTypeFromPath(utString& path) { // Easy out - empty strings are no good! if (path.length() == 0) { return 0; } // Walk backwards to first dot. size_t firstDotPos = path.size() - 1; for (size_t pos = path.size() - 1; pos > 0; pos--) { if (path.at(pos) != '.') { continue; } firstDotPos = pos; break; } // Split out the extension. utString pathExt = path.substr(firstDotPos + 1); // See if we can get a type out of any of the recognizers. int type = 0; for (UTsize i = 0; i < gRecognizerList.size(); i++) { type = gRecognizerList[i](pathExt.c_str()); if (type) { break; } } // No match, so let's use text. if (type == 0) { lmLogInfo(gAssetLogGroup, "Couldn't recognize '%s', defaulting to LATText...", path.c_str()); type = LATText; } return type; }