bool BuildBase::BuildClean(const String& path) { if (buildFailed_) { LOGERRORF("BuildBase::BuildClean - Attempt to clean directory of failed build, %s", path.CString()); return false; } FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (!fileSystem->DirExists(path)) return true; // On Windows, do a little dance with the folder to avoid issues // with deleting folder and immediately recreating it String pathName, fileName, ext; SplitPath(path, pathName, fileName, ext); pathName = AddTrailingSlash(pathName); unsigned i = 0; while (true) { String newPath = ToString("%s%s_Temp_%u", pathName.CString(), fileName.CString(), i++); if (!fileSystem->DirExists(newPath)) { if (!MoveFileExW(GetWideNativePath(path).CString(), GetWideNativePath(newPath).CString(), MOVEFILE_WRITE_THROUGH)) { FailBuild(ToString("BuildBase::BuildClean: Unable to move directory %s -> ", path.CString(), newPath.CString())); return false; } // Remove the moved directory return BuildRemoveDirectory(newPath); } else { LOGWARNINGF("BuildBase::BuildClean - temp build folder exists, removing: %s", newPath.CString()); fileSystem->RemoveDir(newPath, true); } if (i == 255) { FailBuild(ToString("BuildBase::BuildClean: Unable to move directory ( i == 255) %s -> ", path.CString(), newPath.CString())); return false; } } return false; }
bool AndroidProjectGenerator::GenerateStringXML() { FileSystem* fs = GetSubsystem<FileSystem>(); ToolSystem* toolSystem = GetSubsystem<ToolSystem>(); Project* project = toolSystem->GetProject(); AndroidBuildSettings* settings = project->GetBuildSettings()->GetAndroidBuildSettings(); String appName = settings->GetAppName(); if (!appName.Length()) { errorText_ = "Invalid App Name, select the App Name in Build Settings."; return false; } String strings = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; strings += "<resources>\n"; strings.AppendWithFormat("<string name=\"app_name\">%s</string>\n", appName.CString()); strings += "</resources>\n"; // Create res/values if it doesn't exist if (!fs->DirExists(buildPath_ + "/res/values")) { fs->CreateDirsRecursive(buildPath_ + "/res/values"); } // Check that we successfully created it if (!fs->DirExists(buildPath_ + "/res/values")) { errorText_ = "Unable to create directory: " + buildPath_ + "/res/values"; return false; } File file(context_, buildPath_ + "/res/values/strings.xml", FILE_WRITE); if (!file.IsOpen()) { errorText_ = "Unable to write: " + buildPath_ + "/res/values/strings.xml"; return false; } file.Write(strings.CString(), strings.Length()); return true; }
void LicenseSystem::SaveLicense() { FileSystem* filesystem = GetSubsystem<FileSystem>(); String licenseFilePath = filesystem->GetAppPreferencesDir("AtomicEditor", "License"); licenseFilePath = AddTrailingSlash(licenseFilePath); if (!filesystem->DirExists(licenseFilePath)) { Poco::File dirs(licenseFilePath.CString()); dirs.createDirectories(); } licenseFilePath += "AtomicLicense"; SharedPtr<File> file(new File(context_, licenseFilePath, FILE_WRITE)); file->WriteInt(1); // version file->WriteString(key_); file->WriteBool(licenseWindows_); file->WriteBool(licenseMac_); file->WriteBool(licenseAndroid_); file->WriteBool(licenseIOS_); file->WriteBool(licenseHTML5_); file->WriteBool(licenseModule3D_); file->Close(); }
LicenseSystem::LicenseSystem(Context* context) : Object(context) , eulaAgreementConfirmed_(false) { FileSystem* filesystem = GetSubsystem<FileSystem>(); licenseFilePath_ = filesystem->GetAppPreferencesDir("AtomicEditor", "License"); licenseFilePath_ = AddTrailingSlash(licenseFilePath_); if (!filesystem->DirExists(licenseFilePath_)) { Poco::File dirs(licenseFilePath_.CString()); dirs.createDirectories(); } licenseCachePath_ = licenseFilePath_; licenseCachePath_ += "AtomicLicenseCache"; licenseFilePath_ += "AtomicLicense"; eulaAgreementPath_ = filesystem->GetAppPreferencesDir("AtomicEditor", "License"); eulaAgreementPath_ = AddTrailingSlash(eulaAgreementPath_); eulaAgreementPath_ += "EulaConfirmed"; ResetLicense(); }
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); } } }
bool CubemapGenerator::InitPaths() { String scenePath = sceneEditor_->GetFullPath(); String pathName; String fileName; String ext; SplitPath(scenePath, pathName, fileName, ext); outputPathAbsolute_ = pathName + "Cubemaps/" + fileName + "/"; FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (!fileSystem->DirExists(outputPathAbsolute_)) { if (!fileSystem->CreateDirs(pathName, "Cubemaps/" + fileName + "/")) { LOGERRORF("CubemapGenerator::InitRender - Unable to create path: %s", outputPathAbsolute_.CString()); return false; } } // TODO: There should be a better way of getting the resource path ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); resourcePath_ = outputPathAbsolute_; resourcePath_.Replace(project->GetResourcePath(), ""); resourcePath_ = AddTrailingSlash(resourcePath_); return true; }
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(); }
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); }
void AtomicGlowApp::Setup() { IPCClientApp::Setup(); // AtomicGlow is always headless engineParameters_["Headless"] = true; FileSystem* filesystem = GetSubsystem<FileSystem>(); engineParameters_.InsertNew("LogName", filesystem->GetAppPreferencesDir("AtomicEditor", "Logs") + "AtomicGlow.log"); ToolSystem* tsystem = new ToolSystem(context_); context_->RegisterSubsystem(tsystem); ToolEnvironment* env = new ToolEnvironment(context_); context_->RegisterSubsystem(env); String projectPath; for (unsigned i = 0; i < arguments_.Size(); ++i) { if (arguments_[i].Length() > 1) { String argument = arguments_[i].ToLower(); String value = i + 1 < arguments_.Size() ? arguments_[i + 1] : String::EMPTY; if (argument == "--project" && value.Length()) { if (GetExtension(value) == ".atomic") { value = GetPath(value); } if (filesystem->DirExists(value)) { } else { ErrorExit(ToString("%s project path does not exist", value.CString())); } projectPath = AddTrailingSlash(value); } } } if (!env->Initialize()) { ErrorExit("Unable to initialize tool environment from %s"); return; } engineParameters_["ResourcePrefixPaths"] = env->GetRootSourceDir() + "/Resources/"; engineParameters_["ResourcePaths"] = ToString("CoreData;EditorData;%sResources;%sCache", projectPath.CString(), projectPath.CString()); }
void BuildIOS::Build(const String& buildPath) { buildPath_ = buildPath + "/IOS-Build"; Initialize(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(buildPath_)) fileSystem->RemoveDir(buildPath_, true); #ifdef ATOMIC_PLATFORM_WINDOWS String buildSourceDir = fileSystem->GetProgramDir(); #else String buildSourceDir = fileSystem->GetAppBundleResourceFolder(); #endif String buildAppSourceDir = buildSourceDir + "Deployment/IOS/AtomicPlayer.app"; fileSystem->CreateDir(buildPath_); String buildDestDist = buildPath_ + "/AtomicPlayer.app"; fileSystem->CreateDir(buildDestDist); String resourcePackagePath = buildDestDist + "/AtomicResources.pak"; GenerateResourcePackage(resourcePackagePath); fileSystem->Copy(buildAppSourceDir + "/AtomicPlayer", buildDestDist + "/AtomicPlayer"); fileSystem->Copy(buildAppSourceDir + "/PkgInfo", buildDestDist + "/PkgInfo"); BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); IOSBuildSettings settings = buildSystem->GetBuildSettings()->GetIOSSettings(); fileSystem->Copy(settings.provisionFile, buildDestDist + "/embedded.mobileprovision"); String entitlements = GenerateEntitlements(); String plist = GenerateInfoPlist(); File file(context_, buildPath_ + "/AtomicPlayer.app.xcent", FILE_WRITE); if (file.IsOpen()) { file.Write(entitlements.CString(), entitlements.Length()); file.Close(); } File pfile(context_, buildDestDist + "/Info.plist", FILE_WRITE); if (pfile.IsOpen()) { pfile.Write(plist.CString(), plist.Length()); pfile.Close(); } RunConvertPList(); }
void AssetDatabase::Import(const String& path) { FileSystem* fs = GetSubsystem<FileSystem>(); // nothing for now if (fs->DirExists(path)) return; }
void ShaderCompiler::LoadSahders() { FileSystem* fileSystem = new FileSystem(context_); if(!fileSystem->DirExists("../Shaders")) fileSystem->CreateDir("../Shaders"); }
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)); }
void ShaderVariation::SaveByteCode(const String& binaryShaderName) { ResourceCache* cache = owner_->GetSubsystem<ResourceCache>(); FileSystem* fileSystem = owner_->GetSubsystem<FileSystem>(); // Filename may or may not be inside the resource system String fullName = binaryShaderName; if (!IsAbsolutePath(fullName)) { // If not absolute, use the resource dir of the shader String shaderFileName = cache->GetResourceFileName(owner_->GetName()); if (shaderFileName.Empty()) return; fullName = shaderFileName.Substring(0, shaderFileName.Find(owner_->GetName())) + binaryShaderName; } String path = GetPath(fullName); if (!fileSystem->DirExists(path)) fileSystem->CreateDir(path); SharedPtr<File> file(new File(owner_->GetContext(), fullName, FILE_WRITE)); if (!file->IsOpen()) return; file->WriteFileID("USHD"); file->WriteShort((unsigned short)type_); file->WriteShort(3); file->WriteUInt(parameters_.Size()); for (HashMap<StringHash, ShaderParameter>::ConstIterator i = parameters_.Begin(); i != parameters_.End(); ++i) { file->WriteString(i->second_.name_); file->WriteUByte((unsigned char)i->second_.register_); file->WriteUByte((unsigned char)i->second_.regCount_); } unsigned usedTextureUnits = 0; for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i) { if (useTextureUnit_[i]) ++usedTextureUnits; } file->WriteUInt(usedTextureUnits); for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i) { if (useTextureUnit_[i]) { file->WriteString(graphics_->GetTextureUnitName((TextureUnit)i)); file->WriteUByte((unsigned char)i); } } unsigned dataSize = byteCode_.Size(); file->WriteUInt(dataSize); if (dataSize) file->Write(&byteCode_[0], dataSize); }
bool FileUtils::CreateDirs(const String& folder) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); Poco::File dirs(folder.CString()); dirs.createDirectories(); return fileSystem->DirExists(folder); }
void ProjectCmd::HandleProjectBeginLoad(StringHash eventType, VariantMap& eventData) { if (options_ & PROJECTCMD_CACHE_CLEAN) { String cachePath = GetPath(eventData[ProjectBeginLoad::P_PROJECTPATH].GetString()); cachePath = AddTrailingSlash(cachePath) + "Cache"; FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(cachePath) && !fileSystem->RemoveDir(cachePath, true)) Error("Cache clean failed"); } }
String ResourceCache::GetPreferredResourceDir(const String& path) const { String fixedPath = AddTrailingSlash(path); bool pathHasKnownDirs = false; bool parentHasKnownDirs = false; FileSystem* fileSystem = GetSubsystem<FileSystem>(); // If no filesystem, can not check directory existence, so just return the original path if (!fileSystem) return fixedPath; for (unsigned i = 0; !checkDirs[i].Empty(); ++i) { if (fileSystem->DirExists(fixedPath + checkDirs[i])) { pathHasKnownDirs = true; break; } } if (!pathHasKnownDirs) { String parentPath = GetParentPath(fixedPath); for (unsigned i = 0; !checkDirs[i].Empty(); ++i) { if (fileSystem->DirExists(parentPath + checkDirs[i])) { parentHasKnownDirs = true; break; } } // If path does not have known subdirectories, but the parent path has, use the parent instead if (parentHasKnownDirs) fixedPath = parentPath; } return fixedPath; }
String AssetDatabase::GetDotAssetFilename(const String& path) { FileSystem* fs = GetSubsystem<FileSystem>(); String assetFilename = path + ".asset"; if (fs->DirExists(path)) { assetFilename = RemoveTrailingSlash(path) + ".asset"; } return assetFilename; }
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; }
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; }
void FileSelector::SetPath(const String& path) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(path)) { path_ = AddTrailingSlash(path); SetLineEditText(pathEdit_, path_); RefreshFiles(); } else { // If path was invalid, restore the old path to the line edit if (pathEdit_->GetText() != path_) SetLineEditText(pathEdit_, path_); } }
void AssetDatabase::HandleProjectLoaded(StringHash eventType, VariantMap& eventData) { project_ = GetSubsystem<ToolSystem>()->GetProject(); FileSystem* fs = GetSubsystem<FileSystem>(); if (!fs->DirExists(GetCachePath())) fs->CreateDir(GetCachePath()); ResourceCache* cache = GetSubsystem<ResourceCache>(); cache->AddResourceDir(GetCachePath()); Scan(); SubscribeToEvent(E_FILECHANGED, HANDLER(AssetDatabase, HandleFileChanged)); }
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 BuildMac::Build(const String& buildPath) { ToolSystem* tsystem = GetSubsystem<ToolSystem>(); buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder(); Initialize(); BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(buildPath_)) fileSystem->RemoveDir(buildPath_, true); String dataPath = tsystem->GetDataPath(); String appSrcPath = dataPath + "Deployment/MacOS/AtomicPlayer.app"; fileSystem->CreateDir(buildPath_); buildPath_ += "/AtomicPlayer.app"; fileSystem->CreateDir(buildPath_); fileSystem->CreateDir(buildPath_ + "/Contents"); fileSystem->CreateDir(buildPath_ + "/Contents/MacOS"); fileSystem->CreateDir(buildPath_ + "/Contents/Resources"); String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak"; GenerateResourcePackage(resourcePackagePath); fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns"); fileSystem->Copy(appSrcPath + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist"); fileSystem->Copy(appSrcPath + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer"); #ifdef ATOMIC_PLATFORM_OSX Vector<String> args; args.Push("+x"); args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer"); fileSystem->SystemRun("chmod", args); #endif buildPath_ = buildPath + "/Mac-Build"; buildSystem->BuildComplete(PLATFORMID_MAC, buildPath_); }
String Asset::GetDotAssetFilename() { assert(path_.Length()); FileSystem* fs = GetSubsystem<FileSystem>(); String assetFilename = path_ + ".asset"; if (fs->DirExists(path_)) { assetFilename = RemoveTrailingSlash(path_) + ".asset"; } return assetFilename; }
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; }
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; } }
void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventData) { using namespace FileChanged; const String& fullPath = eventData[P_FILENAME].GetString(); FileSystem* fs = GetSubsystem<FileSystem>(); String pathName, fileName, ext; SplitPath(fullPath, pathName, fileName, ext); // ignore changes in the Cache resource dir if (fullPath == GetCachePath() || pathName.StartsWith(GetCachePath())) return; // don't care about directories and asset file changes if (fs->DirExists(fullPath) || ext == ".asset") return; Asset* asset = GetAssetByPath(fullPath); if (!asset && fs->FileExists(fullPath)) { Scan(); return; } if (asset) { if(!fs->Exists(fullPath)) { DeleteAsset(asset); } else { if (asset->GetFileTimestamp() != fs->GetLastModifiedTime(asset->GetPath())) { asset->SetDirty(true); Scan(); } } } }
bool BuildBase::BuildRemoveDirectory(const String& path) { if (buildFailed_) { LOGERRORF("BuildBase::BuildRemoveDirectory - Attempt to remove directory of failed build, %s", path.CString()); return false; } FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (!fileSystem->DirExists(path)) return true; bool result = fileSystem->RemoveDir(path, true); if (!result) { FailBuild(ToString("BuildBase::BuildRemoveDirectory: Unable to remove directory %s", path.CString())); return false; } return true; }
void PlatformAndroid::RefreshAndroidTargets() { if (refreshAndroidTargetsProcess_.NotNull()) return; ToolPrefs* prefs = GetSubsystem<ToolEnvironment>()->GetToolPrefs(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); String androidSDKPath = prefs->GetAndroidSDKPath(); if (!fileSystem->DirExists(androidSDKPath)) { ATOMIC_LOGERRORF("The Android SDK path %s does not exist", androidSDKPath.CString()); return; } SubprocessSystem* subs = GetSubsystem<SubprocessSystem>(); String androidCommand = GetAndroidCommand(); Vector<String> args; PrependAndroidCommandArgs(args); args.Push("list"); args.Push("targets"); targetOutput_.Clear(); refreshAndroidTargetsProcess_ = subs->Launch(androidCommand, args); if (refreshAndroidTargetsProcess_.NotNull()) { SubscribeToEvent(refreshAndroidTargetsProcess_, E_SUBPROCESSCOMPLETE, ATOMIC_HANDLER(PlatformAndroid, HandleRefreshAndroidTargetsEvent)); SubscribeToEvent(refreshAndroidTargetsProcess_, E_SUBPROCESSOUTPUT, ATOMIC_HANDLER(PlatformAndroid, HandleRefreshAndroidTargetsEvent)); } }