当前位置: 首页>>代码示例>>C++>>正文


C++ FileSystem::FileExists方法代码示例

本文整理汇总了C++中FileSystem::FileExists方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::FileExists方法的具体用法?C++ FileSystem::FileExists怎么用?C++ FileSystem::FileExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem::FileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SanitateResourceName

SharedPtr<File> ResourceCache::GetFile(const String& nameIn)
{
    String name = SanitateResourceName(nameIn);
    
    // Check first the packages
    for (unsigned i = 0; i < packages_.Size(); ++i)
    {
        if (packages_[i]->Exists(name))
            return SharedPtr<File>(new File(context_, packages_[i], name));
    }
    
    // Then the filesystem
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    if (fileSystem)
    {
        for (unsigned i = 0; i < resourceDirs_.Size(); ++i)
        {
            if (fileSystem->FileExists(resourceDirs_[i] + name))
            {
                // Construct the file first with full path, then rename it to not contain the resource path,
                // so that the file's name can be used in further GetFile() calls (for example over the network)
                SharedPtr<File> file(new File(context_, resourceDirs_[i] + name));
                file->SetName(name);
                return file;
            }
        }
        
        // Fallback using absolute path
        if (fileSystem->FileExists(name))
            return SharedPtr<File>(new File(context_, name));
    }
    
    LOGERROR("Could not find resource " + name);
    return SharedPtr<File>();
}
开发者ID:acremean,项目名称:urho3d,代码行数:35,代码来源:ResourceCache.cpp

示例2: Exists

bool ResourceCache::Exists(const String& nameIn) const
{
    String name = SanitateResourceName(nameIn);
    
    for (unsigned i = 0; i < packages_.Size(); ++i)
    {
        if (packages_[i]->Exists(name))
            return true;
    }
    
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    if (fileSystem)
    {
        for (unsigned i = 0; i < resourceDirs_.Size(); ++i)
        {
            if (fileSystem->FileExists(resourceDirs_[i] + name))
                return true;
        }
        
        // Fallback using absolute path
        if (fileSystem->FileExists(name))
            return true;
    }
    
    return false;
}
开发者ID:acremean,项目名称:urho3d,代码行数:26,代码来源:ResourceCache.cpp

示例3: DeleteAsset

void AssetDatabase::DeleteAsset(Asset* asset)
{
    SharedPtr<Asset> assetPtr(asset);

    List<SharedPtr<Asset>>::Iterator itr = assets_.Find(assetPtr);

    if (itr == assets_.End())
        return;

    assets_.Erase(itr);

    const String& resourcePath = asset->GetPath();

    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->DirExists(resourcePath))
    {
        fs->RemoveDir(resourcePath, true);
    }
    else if (fs->FileExists(resourcePath))
    {
        fs->Delete(resourcePath);
    }

    String dotAsset = resourcePath + ".asset";

    if (fs->FileExists(dotAsset))
    {
        fs->Delete(dotAsset);
    }

    VariantMap eventData;
    eventData[ResourceRemoved::P_GUID] = asset->GetGUID();
    SendEvent(E_RESOURCEREMOVED, eventData);
}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:35,代码来源:AssetDatabase.cpp

示例4: RemoveLicense

void LicenseSystem::RemoveLicense()
{
    FileSystem* filesystem = GetSubsystem<FileSystem>();

    if (filesystem->FileExists(licenseFilePath_))
    {
        filesystem->Delete(licenseFilePath_);
    }

    if (filesystem->FileExists(licenseCachePath_))
    {
        filesystem->Delete(licenseCachePath_);
    }
}
开发者ID:EternalXY,项目名称:AtomicGameEngine,代码行数:14,代码来源:LicenseSystem.cpp

示例5: CopyUserIcons

bool AndroidProjectGenerator::CopyUserIcons()
{
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    ToolSystem* toolSystem = GetSubsystem<ToolSystem>();
    Project* project = toolSystem->GetProject();
    AndroidBuildSettings* settings = project->GetBuildSettings()->GetAndroidBuildSettings();

    String userIconPath = settings->GetIconPath();
    if (!fileSystem->DirExists(userIconPath))               // dont do anything if there is no path defined.
        return true;
            
    String userIconDir = userIconPath + "/drawable";        // 1st target dir 
    String userIconFile = userIconDir + "/logo_large.png";  // 1st target file
    String destDir = buildPath_ + "/res/drawable";          // where it should be in the build
    if ( fileSystem->FileExists (userIconFile) )            // is there a file there?
    {
        if ( !buildBase_->BuildCopyFile ( userIconFile, destDir + "/logo_large.png" ))
            return false;
    }

    userIconDir = userIconPath + "/drawable-ldpi"; 
    userIconFile = userIconDir + "/icon.png"; 
    destDir = buildPath_ + "/res/drawable-ldpi";
    if ( fileSystem->FileExists (userIconFile) )
    {
        if ( !buildBase_->BuildCopyFile ( userIconFile, destDir + "/icon.png"))
            return false;
    } 

    userIconDir = userIconPath + "/drawable-mdpi"; 
    userIconFile = userIconDir + "/icon.png"; 
    destDir = buildPath_ + "/res/drawable-mdpi";
    {
        if ( !buildBase_->BuildCopyFile ( userIconFile, destDir + "/icon.png" ))
            return false;
    } 

    userIconDir = userIconPath + "/drawable-hdpi"; 
    userIconFile = userIconDir + "/icon.png"; 
    destDir = buildPath_ + "/res/drawable-hdpi";
    if ( fileSystem->FileExists (userIconFile) )
    {
        if ( !buildBase_->BuildCopyFile ( userIconFile, destDir + "/icon.png" ))
            return false;
    }

    return true;
}
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:48,代码来源:AndroidProjectGenerator.cpp

示例6: LoadLicense

bool LicenseSystem::LoadLicense()
{

    ResetLicense();

    FileSystem* filesystem = GetSubsystem<FileSystem>();
    String licenseFilePath = filesystem->GetAppPreferencesDir("AtomicEditor", "License");
    licenseFilePath = AddTrailingSlash(licenseFilePath);
    licenseFilePath += "AtomicLicense";

    if (!filesystem->FileExists(licenseFilePath))
        return false;

    SharedPtr<File> file(new File(context_, licenseFilePath, FILE_READ));

    file->ReadInt(); // version

    String key = file->ReadString();
    if (!ValidateKey(key))
        return false;

    key_ = key;

    licenseWindows_ = file->ReadBool();
    licenseMac_ = file->ReadBool();
    licenseAndroid_ = file->ReadBool();
    licenseIOS_ = file->ReadBool();
    licenseHTML5_ = file->ReadBool();
    licenseModule3D_ = file->ReadBool();

    return true;
}
开发者ID:ezhangle,项目名称:AtomicGameEngine,代码行数:32,代码来源:AELicenseSystem.cpp

示例7: LoadPreferences

    bool AEEditorPrefs::LoadPreferences(JSONValue& prefs)
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        String path = GetPreferencesPath();

        if (!fileSystem->FileExists(path))
        {
            if (!CreateDefaultPreferences(path, prefs))
                return false;
        }
        else
        {
            SharedPtr<File> file(new File(context_, path, FILE_READ));
            SharedPtr<JSONFile> jsonFile(new JSONFile(context_));

            if (!jsonFile->BeginLoad(*file))
            {
                file->Close();
                if (!CreateDefaultPreferences(path, prefs))
                    return false;
            }
            else
            {
                prefs = jsonFile->GetRoot();
            }

            file->Close();
        }

        return true;
    }
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:31,代码来源:AEEditorPrefs.cpp

示例8: CheckCacheFile

bool Asset::CheckCacheFile()
{
    if (importer_.Null())
        return true;

    FileSystem* fs = GetSubsystem<FileSystem>();
    AssetDatabase* db = GetSubsystem<AssetDatabase>();
    String cachePath = db->GetCachePath();

    String cacheFile = cachePath + guid_;

    unsigned modifiedTime = fs->GetLastModifiedTime(path_);

    if (importer_->RequiresCacheFile()) {

        if (!fs->FileExists(cacheFile) || fs->GetLastModifiedTime(cacheFile) < modifiedTime)
            return false;
    }

    if (fs->GetLastModifiedTime(GetDotAssetFilename()) < modifiedTime)
    {
        return false;
    }

    return true;
}
开发者ID:T4RDISDev,项目名称:AtomicGameEngine,代码行数:26,代码来源:Asset.cpp

示例9: HandleNewFolder

void ResourceOps::HandleNewFolder(const String& resourcePath, bool reportError)
{
    Editor* editor = GetSubsystem<Editor>();
    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->DirExists(resourcePath) || fs->FileExists(resourcePath))
    {
        if (reportError)
        {
            String errorMsg;
            errorMsg.AppendWithFormat("Already exists:\n\n %s", resourcePath.CString());
            editor->PostModalError("New Folder Error", errorMsg);
        }

        return;
    }

    if (!fs->CreateDir(resourcePath))
    {
        if (reportError)
        {
            String errorMsg;
            errorMsg.AppendWithFormat("Could not create:\n\n %s", resourcePath.CString());
            editor->PostModalError("New Folder Error", errorMsg);
        }

        return;
    }

    // file watcher doesn't currently handle subdir
    GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();

}
开发者ID:gitter-badger,项目名称:Clockwork,代码行数:33,代码来源:CEResourceOps.cpp

示例10: Initialize

void LicenseSystem::Initialize()
{

    FileSystem* filesystem = GetSubsystem<FileSystem>();
    String eulaConfirmedFilePath = filesystem->GetAppPreferencesDir("AtomicEditor", "License");
    eulaConfirmedFilePath = AddTrailingSlash(eulaConfirmedFilePath);
    eulaConfirmedFilePath += "EulaConfirmed";

    eulaAgreementConfirmed_ = filesystem->FileExists(eulaConfirmedFilePath);

    if (!LoadLicense() || !key_.Length() || !eulaAgreementConfirmed_)
    {
        ResetLicense();
        UIModalOps* ops = GetSubsystem<UIModalOps>();

        if (eulaAgreementConfirmed_)
            ops->ShowActivation();
        else
            ops->ShowEulaAgreement();
    }
    else
    {
        RequestServerVerification(key_);
    }
}
开发者ID:ezhangle,项目名称:AtomicGameEngine,代码行数:25,代码来源:AELicenseSystem.cpp

示例11: Initialize

void LicenseSystem::Initialize()
{

    FileSystem* filesystem = GetSubsystem<FileSystem>();

    eulaAgreementConfirmed_ = filesystem->FileExists(eulaAgreementPath_);

    if (!eulaAgreementConfirmed_)
    {
        SendEvent(E_LICENSE_EULAREQUIRED);
        return;
    }
    else
    {
        SendEvent(E_LICENSE_EULAACCEPTED);
    }

    // TODO: Cleanup for MIT

    if (!LoadLicense() || !key_.Length())
    {
        ResetLicense();

        SendEvent(E_LICENSE_ACTIVATIONREQUIRED);
        return;
    }
    else
    {
        // RequestServerVerification(key_);
    }
}
开发者ID:EternalXY,项目名称:AtomicGameEngine,代码行数:31,代码来源:LicenseSystem.cpp

示例12: HandleProjectLoaded

void NETToolSystem::HandleProjectLoaded(StringHash eventType, VariantMap& eventData)
{
    FileSystem* fileSystem = GetSubsystem<FileSystem>();

    String projectPath = eventData[ProjectLoaded::P_PROJECTPATH].GetString();

    String pathName, fileName, ext;

    SplitPath(projectPath, pathName, fileName, ext);

    String netJSONPath = AddTrailingSlash(pathName) + "AtomicNET.json";

    if (fileSystem->FileExists(netJSONPath))
    {
        SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));

#ifdef ATOMIC_PLATFORM_OSX
        gen->SetScriptPlatform("MACOSX");
#else
        gen->SetScriptPlatform("WINDOWS");
#endif
        gen->LoadProject(netJSONPath, true);

        gen->Generate();

    }

}
开发者ID:Drooids,项目名称:AtomicGameEngine,代码行数:28,代码来源:NETToolSystem.cpp

示例13: PruneOrphanedDotAssetFiles

void AssetDatabase::PruneOrphanedDotAssetFiles()
{

    if (project_.Null())
    {
        LOGDEBUG("AssetDatabase::PruneOrphanedDotAssetFiles - called without project loaded");
        return;
    }

    FileSystem* fs = GetSubsystem<FileSystem>();

    const String& resourcePath = project_->GetResourcePath();

    Vector<String> allResults;

    fs->ScanDir(allResults, resourcePath, "*.asset", SCAN_FILES, true);

    for (unsigned i = 0; i < allResults.Size(); i++)
    {
        String dotAssetFilename = resourcePath + allResults[i];
        String assetFilename = ReplaceExtension(dotAssetFilename, "");

        // remove orphaned asset files
        if (!fs->FileExists(assetFilename) && !fs->DirExists(assetFilename))
        {

            LOGINFOF("Removing orphaned asset file: %s", dotAssetFilename.CString());
            fs->Delete(dotAssetFilename);
        }

    }
}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:32,代码来源:AssetDatabase.cpp

示例14:

bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError)
{

    Editor* editor = GetSubsystem<Editor>();
    Project* project = editor->GetProject();

    String fullpath = resourcePath + resourceName;
    if (!resourceName.EndsWith(".tmx"))
        fullpath += ".tmx";

    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->FileExists(fullpath))
    {
        if (reportError)
        {
            String errorMsg;
            errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString());
            editor->PostModalError("Create 2D Level Error", errorMsg);
        }

        return false;
    }

    return true;

}
开发者ID:gitter-badger,项目名称:Clockwork,代码行数:27,代码来源:CEResourceOps.cpp

示例15: BuildManaged

bool BuildWindows::BuildManaged(const String& buildPath)
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolSystem* toolSystem = GetSubsystem<ToolSystem>();
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    Project* project = toolSystem->GetProject();
    ProjectSettings* settings = project->GetProjectSettings();

    String projectPath = project->GetProjectPath();

#ifdef ATOMIC_DEBUG
    String config = "Debug";
#else
    String config = "Release";
#endif

    String managedBins = projectPath + ToString("AtomicNET/%s/Bin/Desktop/", config.CString());
    String managedExe = managedBins + settings->GetName() + ".exe";

    if (!fileSystem->FileExists(managedExe))
    {
        FailBuild(ToString("Error building managed project, please compile the %s binary %s before building", config.CString(), managedExe.CString()));
        return false;
    }

    StringVector results;
    StringVector filtered;

    fileSystem->ScanDir(results, managedBins, "", SCAN_FILES, false);

    StringVector filterList;

    StringVector::Iterator itr = results.Begin();
    while (itr != results.End())
    {
        unsigned i;
        for (i = 0; i < filterList.Size(); i++)
        {
            if (itr->Contains(filterList[i]))
                break;
        }

        if (i == filterList.Size())
            filtered.Push(*itr);

        itr++;
    }

    for (unsigned i = 0; i < filtered.Size(); i++)
    {
        String filename = filtered[i];

        if (!BuildCopyFile(managedBins + filename, buildPath_ + "/" + filename))
            return false;

    }

    return true;

}
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:60,代码来源:BuildWindows.cpp


注:本文中的FileSystem::FileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。