Пример #1
0
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>();
}
Пример #2
0
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;
}
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);
}
Пример #4
0
void LicenseSystem::RemoveLicense()
{
    FileSystem* filesystem = GetSubsystem<FileSystem>();

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

    if (filesystem->FileExists(licenseCachePath_))
    {
        filesystem->Delete(licenseCachePath_);
    }
}
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;
}
Пример #6
0
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;
}
    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;
    }
Пример #8
0
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;
}
Пример #9
0
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();

}
Пример #10
0
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_);
    }
}
Пример #11
0
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_);
    }
}
Пример #12
0
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();

    }

}
Пример #13
0
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);
        }

    }
}
Пример #14
0
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;

}
Пример #15
0
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;

}
Пример #16
0
void FileUtils::RevealInFinder(const String& fullpath)
{
    FileSystem* fs = GetSubsystem<FileSystem>();
    if (fs->DirExists(fullpath))
        fs->SystemOpen(fullpath);
    else if (fs->FileExists(fullpath))
        fs->SystemOpen(GetPath(fullpath));
}
Пример #17
0
bool TextureImporter::Import()
{
    AssetDatabase* db = GetSubsystem<AssetDatabase>();
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    String cachePath = db->GetCachePath();

    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    String compressedPath = cachePath + "DDS/" + asset_->GetRelativePath() + ".dds";
    if (fileSystem->FileExists(compressedPath))
        fileSystem->Delete(compressedPath);

    SharedPtr<Image> image = cache->GetTempResource<Image>(asset_->GetPath());

    if (image.Null())
        return false;

    if (compressTextures_ &&
        !image->IsCompressed())
    {
        fileSystem->CreateDirs(cachePath, "DDS/" + Atomic::GetPath(asset_->GetRelativePath()));

		float resizefactor;
		float width = image->GetWidth();
		float height = image->GetHeight();

		if (width > compressedSize_ || height > compressedSize_)
		{
			if (width >= height)
			{
				resizefactor = compressedSize_ / width;
			}
			else
			{
				resizefactor = compressedSize_ / height;
			}

			image->Resize(width*resizefactor, height*resizefactor);
		}

		if (image->SaveDDS(compressedPath))
		{			
			Renderer * renderer = GetSubsystem<Renderer>();
			renderer->ReloadTextures();
		}
    }

    // todo, proper proportions
    image->Resize(64, 64);

    // not sure entirely what we want to do here, though if the cache file doesn't exist
    // will reimport
    image->SavePNG(cachePath + asset_->GetGUID());

    // save thumbnail
    image->SavePNG(cachePath + asset_->GetGUID() + "_thumbnail.png");

    return true;
}
Пример #18
0
void ToolEnvironment::SetRootBuildDir(const String& buildDir, bool setBinaryPaths)
{
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    rootBuildDir_ = AddTrailingSlash(buildDir);


    if (setBinaryPaths)
    {
#ifdef ATOMIC_PLATFORM_WINDOWS

#ifdef _DEBUG
        playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/Application/Debug/AtomicPlayer.exe";
        editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/Debug/AtomicEditor.exe";
#else
        playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/Application/Release/AtomicPlayer.exe";
        editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/Release/AtomicEditor.exe";
#endif

        // some build tools like ninja don't use Release/Debug folders
        if (!fileSystem->FileExists(playerBinary_))
                playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/Application/AtomicPlayer.exe";
        if (!fileSystem->FileExists(editorBinary_))
                editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/AtomicEditor.exe";

        playerAppFolder_ = rootSourceDir_ + "Data/AtomicEditor/Deployment/MacOS/AtomicPlayer.app";

#elif ATOMIC_PLATFORM_OSX

#ifdef ATOMIC_XCODE
        playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/" + CMAKE_INTDIR + "/AtomicPlayer.app/Contents/MacOS/AtomicPlayer";
        editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/" + CMAKE_INTDIR + "/AtomicEditor.app/Contents/MacOS/AtomicEditor";
#else
        playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/Application/AtomicPlayer.app/Contents/MacOS/AtomicPlayer";
        playerAppFolder_ = rootBuildDir_ + "Source/AtomicPlayer/Application/AtomicPlayer.app/";
        editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/AtomicEditor.app/Contents/MacOS/AtomicEditor";
#endif

#else
        playerBinary_ = rootBuildDir_ + "Source/AtomicPlayer/Application/AtomicPlayer";
        editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/AtomicEditor";

#endif
    }

}
Пример #19
0
void Asset::UpdateFileTimestamp()
{
    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->FileExists(path_))
    {
        fileTimestamp_ = fs->GetLastModifiedTime(path_);
    }
}
void GameEconomicGameClientStateSplash::SplashStatInit(void)
{
/// Get Needed SubSystems
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Renderer* renderer = GetSubsystem<Renderer>();
    Graphics* graphics = GetSubsystem<Graphics>();
    UI* ui = GetSubsystem<UI>();

    FileSystem * filesystem = GetSubsystem<FileSystem>();

    /// Create variables (urho3d)
    String InputDataFile;

    InputDataFile.Append(filesystem->GetProgramDir().CString());
    InputDataFile.Append("Resources/Scenes/");
    InputDataFile.Append("Login1.xml");

    bool success;
    /// Check if the input data file exist
    if(filesystem->FileExists(InputDataFile))
    {
        /// Open file as a Urho3d Datafile
        dataFile = new File(context_, InputDataFile, FILE_READ);

        if (dataFile -> IsOpen())
        {

            /// Get File Extension
            String extension = GetExtension(InputDataFile);


            /// Determine file extension
            if (extension != ".xml")
            {
                ///success= Existence-> scene_ -> Load(dataFile);
                success = Existence-> scene_ -> LoadAsync(dataFile);
            }
            else
            {
                success= Existence-> scene_ ->LoadAsyncXML(dataFile);
            }
        }
        else
        {
            /// set is error
            success=false;
        }

    }

    /// on update
    SubscribeToEvent(E_UPDATE, HANDLER(GameEconomicGameClientStateSplash, HandlerSplashUpdate)); // Keep visible until rendering of the scene

    return;
}
/// Save account information to a file
void GameEconomicGameClient::SaveConfiguration(Configuration &configuration)
{
    /// Get Resource
    ResourceCache * cache = GetSubsystem<ResourceCache>();
    FileSystem * fileSystem = GetSubsystem<FileSystem>();

    String configFileName;

    /// Set directory and path for network file
    configFileName.Append(fileSystem->GetProgramDir().CString());
    configFileName.Append("");
    configFileName.Append("Configuration.xml");


    /// Check if the account file information exist
    if(fileSystem->FileExists(configFileName.CString()))
    {
        fileSystem->Delete(configFileName.CString());
    }

    cout << "It got here "<<endl;

    File saveFile(context_, configFileName.CString(), FILE_WRITE);

    XMLFile * preferencefileconfig  = new XMLFile(context_);

    XMLElement configElem = preferencefileconfig   -> CreateRoot("Configuration");
    XMLElement GameModeConfigurationElement = configElem.CreateChild("GameModeConfiguration");
    XMLElement VideoConfigurationElement= configElem.CreateChild("VideoConfiguration");

    /// Set true false
    if(configuration.GameModeForceTablet==true)
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "true");
    }
    else
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "false");
    }

    /// Convert video bloom to float
    String VideoBloomParamValue1String(configuration.VideoBloomParam1);
    String VideoBloomParamValue2String(configuration.VideoBloomParam2);

    /// Copy values testing
    VideoConfigurationElement.SetAttribute("BloomParam1",VideoBloomParamValue1String);
    VideoConfigurationElement.SetAttribute("BloomParam2",VideoBloomParamValue2String);

    preferencefileconfig->Save(saveFile);

    return;
}
Пример #22
0
    void NETAtomicPlayer::ReadEngineConfig()
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        String filename = fileSystem->GetProgramDir() + "Settings/Engine.json";

        if (!fileSystem->FileExists(filename))
            return;

        if (EngineConfig::LoadFromFile(context_, filename))
        {
            EngineConfig::ApplyConfig(engineParameters_, true);
        }
    }
Пример #23
0
void LicenseSystem::RemoveLicense()
{
    FileSystem* filesystem = GetSubsystem<FileSystem>();

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

    if (filesystem->FileExists(licenseFilePath))
    {
        filesystem->Delete(licenseFilePath);
    }
}
Пример #24
0
String ResourceCache::GetResourceFileName(const String& name) const
{
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    if (fileSystem)
    {
        for (unsigned i = 0; i < resourceDirs_.Size(); ++i)
        {
            if (fileSystem->FileExists(resourceDirs_[i] + name))
                return resourceDirs_[i] + name;
        }
    }
    
    return String();
}
Пример #25
0
void LicenseSystem::CreateOrUpdateLicenseCache()
{
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    Time* time = GetSubsystem<Time>();

    if (!fileSystem->FileExists(licenseCachePath_))
    {
        SharedPtr<File> file(new File(context_, licenseCachePath_, FILE_WRITE));
        file->WriteInt(1);
        file->Close();
    }

    fileSystem->SetLastModifiedTime(licenseCachePath_, time->GetTimeSinceEpoch());
}
bool AndroidProjectGenerator::GenerateLocalProperties( )
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();
    String sdkPath = prefs->GetAndroidSDKPath();

    if (!sdkPath.Length())
    {
        errorText_ = "Invalid Android SDK Path, select the path in Build Settings.";
        return false;
    }

    String props;
    props.AppendWithFormat("sdk.dir=%s", sdkPath.CString());

    File file(context_, buildPath_ + "/local.properties", FILE_WRITE);

    if (!file.IsOpen())
    {
        errorText_ = "Project generator unable to open file " + buildPath_ + "/local.properties ";
        return false;
    }
    
    file.Write(props.CString(), props.Length());


    if ( prefs->GetReleaseCheck() > 2 ) // if release index is set ...
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        String Reldir = prefs->GetReleasePath();
        if (!fileSystem->DirExists(Reldir))
        {
            errorText_ = "Invalid Release Path, select the path in Build Settings.";
            return false;
        }
        
        String antname = Reldir + "/ant.properties";
        if ( !fileSystem->FileExists ( antname) ) 
        {
            errorText_ = "The file ant.properties not found in " + Reldir + ", unable to generate Release APK.";
            return false;
        }

        if ( !buildBase_->BuildCopyFile ( antname, buildPath_ + "/ant.properties" ))
            return false;

    }
    return true;

}
Пример #27
0
bool AssetImporter::Rename(const String& newName)
{
    String pathName, fileName, ext;

    SplitPath(asset_->path_, pathName, fileName, ext);

    String newPath = pathName + newName + ext;

    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->FileExists(newPath) || fs->DirExists(newPath))
        return false;

    return Move(newPath);

}
    void NETAtomicPlayer::ReadEngineConfig()
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();

#ifdef ATOMIC_PLATFORM_OSX
        String filename = fileSystem->GetProgramDir() + "../Resources/Settings/Engine.json";
#else
        String filename = fileSystem->GetProgramDir() + "Settings/Engine.json";
#endif

        if (!fileSystem->FileExists(filename))
            return;

        if (EngineConfig::LoadFromFile(context_, filename))
        {
            EngineConfig::ApplyConfig(engineParameters_, true);
        }
    }
Пример #29
0
void ResourceOps::HandleResourceDelete(const String& resourcePath, bool reportError)
{
    Editor* editor = GetSubsystem<Editor>();
    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->DirExists(resourcePath))
    {
        fs->RemoveDir(resourcePath, true);

        GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();

        return;
    }
    else if (fs->FileExists(resourcePath))
    {
        if (!fs->Delete(resourcePath))
        {
            if (reportError)
            {
                String errorMsg;
                errorMsg.AppendWithFormat("Unable to delete:\n\n %s", resourcePath.CString());
                editor->PostModalError("Delete Resource Error", errorMsg);
            }

            return;
        }

        GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();

        return;
    }
    else
    {
        if (reportError)
        {
            String errorMsg;
            errorMsg.AppendWithFormat("Unable to find:\n\n %s", resourcePath.CString());
            editor->PostModalError("Delete Resource Error", errorMsg);
        }

        return;
    }

}
bool AndroidProjectGenerator::CopyDebugGdbserver()
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();

    // include gdbserver in APK
    if ( prefs->GetReleaseCheck() == 1 || prefs->GetReleaseCheck() == 2 ) 
    {
        String ndkPath = prefs->GetNdkPath();    
        if (ndkPath.Empty())
        {
            errorText_ = "NDK path not entered, this is required to add gdbserver to APK";
            return false;
        }

        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        if (!fileSystem->DirExists(ndkPath))
        {
            errorText_ = "Invalid NDK Path, can not add gdbserver to APK.";
            return false;
        }

        // copy gdbserver file
        String gsstring = ndkPath + "/prebuilt/android-arm/gdbserver/gdbserver";  // assume arm type abi
        String destDir = buildPath_ + "/libs/armeabi-v7a"; // assume armeabi-v7a abi type
        if ( !fileSystem->FileExists (gsstring) )
        {
            errorText_ = "gdbserver not found as " + gsstring;
            return false;
        }
        
        if ( prefs->GetReleaseCheck() == 1 ) // Debug Source with gdbserver
        {
            if ( !buildBase_->BuildCopyFile ( gsstring, destDir + "/gdbserver"))
                return false;
        } 
        else if ( prefs->GetReleaseCheck() == 2 ) // Debug Source with libgdbserver.so
        {
            if ( !buildBase_->BuildCopyFile ( gsstring, destDir + "/libgdbserver.so"))
                return false;
        } 
    }
    return true;
}