private bool InitializeTargetDirectory() { if (mConsoleCopy) { if (!XboxUtils.FileExist(mSyncRoot)) { if (!XboxUtils.DirectoryCreateVerify(mSyncRoot, true)) { // Error //MOG_REPORT.ShowMessageBox("Xbox Dir Error", string.Concat(mSyncRoot, " could not be created!"), MessageBoxButtons.OK); throw new Exception(mSyncRoot + " could not be created!"); } } } else { // Create the initial directory on the pc if (!DosUtils.Exist(mSyncRoot)) { try { Directory.CreateDirectory(mSyncRoot); } catch (Exception e) { // Error MOG_REPORT.ShowMessageBox("Dir Error", string.Concat(mSyncRoot, " could not be created!", "\n", e.ToString()), MessageBoxButtons.OK); throw new Exception(mSyncRoot + " could not be created!", e); //return false; } } } return(true); }
public ArrayList LocateAssetBinary(MOG_Filename filename, AssetDirectories AssetDirectoryType) { string targetDir = ""; ArrayList binaryFiles = new ArrayList(); MOG_Properties assetProperties = new MOG_Properties(filename); switch (AssetDirectoryType) { case AssetDirectories.IMPORTED: targetDir = MOG_ControllerAsset.GetAssetImportedDirectory(assetProperties); break; case AssetDirectories.PROCESSED: string platformName = ""; // If we have a valid gameDataController? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { platformName = MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName(); } targetDir = MOG_ControllerAsset.GetAssetProcessedDirectory(assetProperties, platformName); break; } if (targetDir.Length != 0 && DosUtils.Exist(targetDir)) { FileInfo [] files = DosUtils.FileGetList(targetDir, "*.*"); foreach (FileInfo file in files) { binaryFiles.Add(file.FullName); } } else { MOG_Prompt.PromptMessage("Asset View", "Asset (" + targetDir + ") does not exist or is a zero length file! Cannot View.", Environment.StackTrace); } return(binaryFiles); }
public void View(MOG_Filename filename, AssetDirectories AssetDirectoryType, string viewer) { viewer = viewer.ToLower(); // Onlcy create viewer processes for real viewers, not none if (viewer.Length > 0) { try { viewer = MOG_Tokens.GetFormattedString(viewer, MOG_Tokens.GetProjectTokenSeeds(MOG_ControllerProject.GetProject())); // Does this viewer have an extension if (Path.GetExtension(viewer).Length == 0) { // Try tacking on an exe just for good measure viewer += ".exe"; } // Check to see if we can find the tool with the path provided if (!DosUtils.Exist(viewer)) { try { string locatedViewer = MOG_ControllerSystem.LocateTool(Path.GetDirectoryName(viewer), Path.GetFileName(viewer)); if (!String.IsNullOrEmpty(locatedViewer)) { viewer = locatedViewer; } } catch (Exception e) { MOG_Report.ReportMessage("Located Viewer", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL); } } } catch (Exception e2) { MOG_Report.ReportMessage("Located Viewer", e2.Message, e2.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL); } // Get the binary files for this asset ArrayList binaryFiles = LocateAssetBinary(filename, AssetDirectoryType); if (binaryFiles.Count > 5) { if (MOG_Prompt.PromptResponse("Asset View", "There are (" + binaryFiles.Count.ToString() + ") files to be viewed in this asset.\n\nShould we continue and launch one viewer per file?", MOGPromptButtons.OKCancel) == MOGPromptResult.Cancel) { return; } } // Make sure viewer exists foreach (string binary in binaryFiles) { AssetView assetViewer = new AssetView(); assetViewer.Asset = filename; // If we have a viewer, we need to put quotes around our binary so that its arguments line up if (viewer.Length > 0) { assetViewer.Binary = "\"" + binary + "\""; assetViewer.Viewer = viewer; //} //else //{ // // If we don't have a viewer, we will be launching the biniary its self. // // Therefore, set the binary without quotes // assetViewer.Binary = binary; // assetViewer.Viewer = ""; } Thread viewerThread = new Thread(new ThreadStart(assetViewer.ShellSpawnWithLock)); viewerThread.Start(); } } else { MOG_Report.ReportMessage("View", "No viewer defined for this asset!", "", MOG_ALERT_LEVEL.ALERT); } }
private bool InitializeFileMap() { mPlatformSync = new MOG_Ini(); // Get the platformSinc.info file string platformSyncFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mProjectSyncFile; if (DosUtils.Exist(platformSyncFile)) { // Open the global sinc file to determine what to sinc mPlatformSync.Open(platformSyncFile, FileShare.Read); mPlatformSync.SetFilename(mMog.GetUser().GetUserToolsPath() + "\\platformSinc." + mMog.GetActivePlatform().mPlatformName + ".Merge.info", false); } // Check if the user has a custom sync file string userSyncFile = mMog.GetUser().GetUserToolsPath() + "\\" + mUserSyncFile; if (DosUtils.FileExist(userSyncFile)) { // Should we force ourselves to use only the user sync file? if (string.Compare(mProjectSyncFile, "none", true) == 0) { mPlatformSync.CloseNoSave(); mPlatformSync.Open(userSyncFile, FileShare.Read); } else { // Lets merge the two then mPlatformSync.PutFile(userSyncFile); } } // Make sure we got 'a' Map file loaded if (mPlatformSync.GetFilename().Length > 0) { // Is this a local sync if (Path.IsPathRooted(mTargetConsole)) { string root = ""; // Get our local directory root path // Get our console root path if (mUseDefaultUser) { root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower()); } else { root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower()); } // Fix up the pc console name mSyncRoot = mTargetConsole + "\\" + Path.GetFileNameWithoutExtension(root); mConsoleCopy = false; } else { // Get our console root path if (mUseDefaultUser) { mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower()); } else { mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower()); } } } else { throw(new Exception("Valid platform sync file never properly loaded!")); } return(true); }