Ejemplo n.º 1
0
// 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;
}
Ejemplo n.º 2
0
static loom_asset_t *loom_asset_getAssetByName(const char *name, int create)
{
    utHashedString key        = platform_normalizePath(name);
    loom_asset_t   **assetPtr = gAssetHash.get(key);
    loom_asset_t   *asset     = assetPtr ? *assetPtr : NULL;

    if ((asset == NULL) && create)
    {
        // Create one.
        asset       = lmNew(gAssetAllocator) loom_asset_t;
        asset->name = strdup(name);
        gAssetHash.insert(key, asset);
    }

    return asset;
}
Ejemplo n.º 3
0
static loom_asset_t *loom_asset_getAssetByName(const char *name, int create)
{
    loom_mutex_lock(gAssetLock);
    static char normalized[4096];
    strncpy(normalized, name, sizeof(normalized));
    platform_normalizePath(normalized);
    utHashedString key        = normalized;
    loom_mutex_unlock(gAssetLock);
    loom_asset_t   **assetPtr = gAssetHash.get(key);
    loom_asset_t   *asset     = assetPtr ? *assetPtr : NULL;

    if ((asset == NULL) && create)
    {
        // Create one.
        asset       = lmNew(gAssetAllocator) loom_asset_t;
        asset->name = name;
        gAssetHash.insert(key, asset);
    }

    return asset;
}