bool Project::Load(const String& fullpath) { loading_ = true; if (fullpath.Contains(".atomic")) { projectPath_ = AddTrailingSlash(GetPath(fullpath)); projectFilePath_ = fullpath; } else { projectPath_ = AddTrailingSlash(fullpath); projectFilePath_ = projectPath_ + GetFileName(RemoveTrailingSlash(projectPath_)) + ".atomic"; } SharedPtr<ProjectFile> pfile(new ProjectFile(context_)); bool result = pfile->Load(this); loading_ = false; LoadBuildSettings(); LoadUserPrefs(); if ( true /*result*/) { VariantMap data; data[ProjectLoaded::P_PROJECTPATH] = projectFilePath_; SendEvent(E_PROJECTLOADED, data); } return result; }
std::string AlloyContext::getFullPath(const std::string& partialFile) { std::string fileName = partialFile; if (ALY_PATH_SEPARATOR[0] != '/') { for (char& c : fileName) { if (c == '/') { c = ALY_PATH_SEPARATOR[0]; } } } else if (ALY_PATH_SEPARATOR[0] != '\\') { for (char& c : fileName) { if (c == '\\') { c = ALY_PATH_SEPARATOR[0]; } } } for (std::string& dir : assetDirectories) { std::string fullPath = RemoveTrailingSlash(dir) + ALY_PATH_SEPARATOR+ fileName; if (FileExists(fullPath)) { return fullPath; } } std::string executableDir = GetExecutableDirectory(); for (std::string& dir : assetDirectories) { std::string fullPath = RemoveTrailingSlash(executableDir) + ALY_PATH_SEPARATOR+ RemoveTrailingSlash(dir) + ALY_PATH_SEPARATOR + fileName; if (FileExists(fullPath)) { return fullPath; } } std::cout << "Could not find \"" << fileName << "\"\nThis is where I looked:" << std::endl; for (std::string& dir : assetDirectories) { std::string fullPath = RemoveTrailingSlash(dir) + ALY_PATH_SEPARATOR+ fileName; std::cout << "\"" << fullPath << "\"" << std::endl; fullPath = executableDir + ALY_PATH_SEPARATOR + RemoveTrailingSlash(dir) + ALY_PATH_SEPARATOR + fileName; std::cout << "\"" << fullPath << "\"" << std::endl; } throw std::runtime_error( MakeString() << "Could not find \"" << fileName << "\""); return std::string(""); }
Asset* Asset::GetParent() { AssetDatabase* db = GetSubsystem<AssetDatabase>(); String pathName; String fileName; String ext; SplitPath(path_, pathName, fileName, ext); return db->GetAssetByPath(RemoveTrailingSlash(pathName)); }
String Asset::GetDotAssetFilename() { assert(path_.Length()); FileSystem* fs = GetSubsystem<FileSystem>(); String assetFilename = path_ + ".asset"; if (fs->DirExists(path_)) { assetFilename = RemoveTrailingSlash(path_) + ".asset"; } return assetFilename; }
void __fastcall TfmLauncher::ProcessConfigFile() { if (FileExists(ConfigFileName)){ TStringList *ConfigFile = new TStringList(); __try{ ConfigFile->LoadFromFile(ConfigFileName); RootDirectory = ConfigFile->Values[cRootDirectory]; FileName = ConfigFile->Values[cFileName]; FileName = RemoveTrailingSlash(RootDirectory) + '\\' + RemoveLeadingSlash(FileName); } __finally{ delete ConfigFile; } } }
bool ToolEnvironment::InitFromDistribution() { toolPrefs_->Load(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_WINDOWS editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor.exe"; String resourcesDir = fileSystem->GetProgramDir() + "Resources/"; playerBinary_ = resourcesDir + "ToolData/Deployment/Windows/x64/AtomicPlayer.exe"; #elif ATOMIC_PLATFORM_LINUX editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor"; String resourcesDir = fileSystem->GetProgramDir() + "Resources/"; playerBinary_ = resourcesDir + "ToolData/Deployment/Linux/AtomicPlayer"; #else editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor"; String resourcesDir = GetPath(RemoveTrailingSlash(fileSystem->GetProgramDir())) + "Resources/"; playerAppFolder_ = resourcesDir + "ToolData/Deployment/MacOS/AtomicPlayer.app/"; #endif resourceCoreDataDir_ = resourcesDir + "CoreData"; resourcePlayerDataDir_ = resourcesDir + "PlayerData"; toolDataDir_ = resourcesDir + "ToolData/"; // AtomicNET #ifdef ATOMIC_DEBUG String config = "Debug"; #else String config = "Release"; #endif atomicNETRootDir_ = resourcesDir + "ToolData/AtomicNET/"; atomicNETCoreAssemblyDir_ = atomicNETRootDir_ + config + "/"; #ifdef ATOMIC_PLATFORM_OSX monoExecutableDir_ = "/Library/Frameworks/Mono.framework/Versions/Current/Commands/"; atomicNETNuGetBinary_ = monoExecutableDir_ + "nuget"; #endif return true; }
bool Asset::CreateImporter() { assert(importer_.Null()); FileSystem* fs = GetSubsystem<FileSystem>(); if (fs->DirExists(path_)) { name_ = GetFileName(RemoveTrailingSlash(path_)); isFolder_ = true; importer_ = new FolderImporter(context_, this); } else { String ext = Atomic::GetExtension(path_); name_ = GetFileName(path_); Vector<String> textureFormats; textureFormats.Push(".jpg"); textureFormats.Push(".png"); textureFormats.Push(".tga"); textureFormats.Push(".dds"); // todo, externalize recognizers if (ext == ".fbx" || ext == ".blend" || ext == ".dae" || ext == ".mdl") { importer_ = new ModelImporter(context_, this); } if (ext == ".ogg" || ext == ".wav") { importer_ = new AudioImporter(context_, this); } else if (ext == ".prefab") { importer_ = new PrefabImporter(context_, this); } else if (ext == ".js") { importer_ = new JavascriptImporter(context_, this); } else if (ext == ".ts") { importer_ = new TypeScriptImporter(context_, this); } else if (ext == ".json") { importer_ = new JSONImporter(context_, this); } else if (ext == ".scene") { importer_ = new SceneImporter(context_, this); } else if (ext == ".material") { importer_ = new MaterialImporter(context_, this); } else if (ext == ".scml") { importer_ = new SpriterImporter(context_, this); } else if (ext == ".tmx") { importer_ = new TMXImporter(context_, this); } else if (ext == ".pex") { importer_ = new PEXImporter(context_, this); } else if (ext == ".peffect") { importer_ = new ParticleEffectImporter(context_, this); } else if (ext == ".txt" || ext == ".xml" || ext == ".hlsl" || ext == ".glsl") { importer_ = new TextImporter(context_, this); } else if (ext == ".dll") { // TODO: check for native dll #ifdef ATOMIC_DOTNET importer_ = new NETAssemblyImporter(context_, this); #endif } else if (textureFormats.Contains(ext)) { importer_ = new TextureImporter(context_, this); } } if (importer_.Null()) return false; return true; }
void BuildAndroid::Build(const String& buildPath) { ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>(); ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder(); Initialize(); if (!BuildClean(buildPath_)) return; //generate manifest file String manifest; for (unsigned i = 0; i < resourceEntries_.Size(); i++) { BuildResourceEntry* entry = resourceEntries_[i]; manifest += entry->packagePath_; if ( i != resourceEntries_.Size() - 1) manifest += ";"; } String buildSourceDir = tenv->GetToolDataDir(); String androidProject = buildSourceDir + "Deployment/Android"; // Copy the base android project FileSystem* fileSystem = GetSubsystem<FileSystem>(); if( !BuildCopyDir(androidProject, buildPath_)) return; Vector<String> defaultResourcePaths; GetDefaultResourcePaths(defaultResourcePaths); String projectResources = project->GetResourcePath(); for (unsigned i = 0; i < defaultResourcePaths.Size(); i++) { if ( !BuildCopyDir(defaultResourcePaths[i], buildPath_ + "/assets/" + GetFileName(RemoveTrailingSlash(defaultResourcePaths[i])))) return; } if( !BuildCopyDir(project->GetProjectPath() + "Cache/", buildPath_ + "/assets/Cache")) return; if( !BuildCopyDir(projectResources, buildPath_ + "/assets/AtomicResources")) return; // write the manifest SharedPtr<File> mfile(new File(context_, buildPath_ + "/assets/AtomicManifest", FILE_WRITE)); mfile->WriteString(manifest); mfile->Close(); //check for Deployment/Android/libs/armeabi-v7a/libAtomicPlayer.so if ( !fileSystem->FileExists(androidProject + "/libs/armeabi-v7a/libAtomicPlayer.so") ) { FailBuild( "The file libAtomicPlayer.so is not found. This is required for APK generation." ); return; } AndroidProjectGenerator gen(context_, this); gen.SetBuildPath(buildPath_); if (!gen.Generate()) { FailBuild(gen.GetErrorText()); return; } RunAntDebug(); }
bool FileWatcher::StartWatching(const String& pathName, bool watchSubDirs) { if (!fileSystem_) { LOGERROR("No FileSystem, can not start watching"); return false; } // Stop any previous watching StopWatching(); #if defined(ENABLE_FILEWATCHER) #if defined(WIN32) String nativePath = GetNativePath(RemoveTrailingSlash(pathName)); dirHandle_ = (void*)CreateFileW( WString(nativePath).CString(), FILE_LIST_DIRECTORY, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (dirHandle_ != INVALID_HANDLE_VALUE) { path_ = AddTrailingSlash(pathName); watchSubDirs_ = watchSubDirs; Start(); LOGDEBUG("Started watching path " + pathName); return true; } else { LOGERROR("Failed to start watching path " + pathName); return false; } #elif defined(__linux__) int flags = IN_CREATE|IN_DELETE|IN_MODIFY|IN_MOVED_FROM|IN_MOVED_TO; int handle = inotify_add_watch(watchHandle_, pathName.CString(), flags); if (handle < 0) { LOGERROR("Failed to start watching path " + pathName); return false; } else { // Store the root path here when reconstructed with inotify later dirHandle_[handle] = ""; path_ = AddTrailingSlash(pathName); watchSubDirs_ = watchSubDirs; if (watchSubDirs_) { Vector<String> subDirs; fileSystem_->ScanDir(subDirs, pathName, "*", SCAN_DIRS, true); for (unsigned i = 0; i < subDirs.Size(); ++i) { String subDirFullPath = AddTrailingSlash(path_ + subDirs[i]); // Don't watch ./ or ../ sub-directories if (!subDirFullPath.EndsWith("./")) { handle = inotify_add_watch(watchHandle_, subDirFullPath.CString(), flags); if (handle < 0) LOGERROR("Failed to start watching subdirectory path " + subDirFullPath); else { // Store sub-directory to reconstruct later from inotify dirHandle_[handle] = AddTrailingSlash(subDirs[i]); } } } } Start(); LOGDEBUG("Started watching path " + pathName); return true; } #elif defined(__APPLE__) && !defined(IOS) if (!supported_) { LOGERROR("Individual file watching not supported by this OS version, can not start watching path " + pathName); return false; } watcher_ = CreateFileWatcher(pathName.CString(), watchSubDirs); if (watcher_) { path_ = AddTrailingSlash(pathName); watchSubDirs_ = watchSubDirs; Start(); LOGDEBUG("Started watching path " + pathName); return true; } else { LOGERROR("Failed to start watching path " + pathName); return false; } #else LOGERROR("FileWatcher not implemented, can not start watching path " + pathName); return false; #endif #else LOGDEBUG("FileWatcher feature not enabled"); return false; #endif }