public void LoadModule(string moduleName) { if (moduleName.Contains("\\") == false) { moduleName = "Hdd:\\" + moduleName; } if (!FileExists(moduleName)) { return; } if (IsModuleLoaded(moduleName)) { XboxUtils.ErrorMessage(moduleName + " is already loaded."); return; } try { XboxUtils.Call <uint>("xboxkrnl.exe", 409, new object[] { moduleName, 8, 0, 0 }); XboxUtils.ConfirmMessage(moduleName + " has been loaded."); } catch (Exception) { XboxUtils.ErrorMessage("Could not load module: " + moduleName); } }
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 void UnloadModule(string moduleName) { if (!FileExists(moduleName)) { return; } if (!IsModuleLoaded(moduleName)) { XboxUtils.ErrorMessage(moduleName + " is not loaded."); return; } try { uint handle = XboxUtils.Call <uint>("xam.xex", 1102, new object[] { moduleName }); if (handle != 0u) { XboxUtils.WriteShort(handle + 0x40, 1); XboxUtils.Call <uint>("xboxkrnl.exe", 417, new object[] { handle }); XboxUtils.ConfirmMessage(moduleName + " has been unloaded."); } else { XboxUtils.ErrorMessage("Could not unload module: " + moduleName); } } catch (Exception) { XboxUtils.ErrorMessage("Could not unload module: " + moduleName); } }
private bool CreateTargetDirectoryPath(string targetPath) { // Check for a sub-dir int index = targetPath.LastIndexOf("\\"); if (index != -1 && targetPath[index - 1] != ':') { string RootDir = targetPath.Substring(0, index); if (!CreateTargetDirectoryPath(RootDir)) { return(false); } } if (mConsoleCopy) { // Check if it already exists if (!XboxUtils.FileExist(targetPath)) { // if (!XboxUtils.DirectoryCreateVerify(targetPath, false)) { // Error MOG_REPORT.ShowMessageBox("Create Target Directory Path", string.Concat(RemapDirectoryString(targetPath), " could not be created!"), MessageBoxButtons.OK); return(false); } XboxUtils.DM_FILE_ATTRIBUTES att = new XboxUtils.DM_FILE_ATTRIBUTES(); XboxUtils.GetFileAttributes(targetPath, ref att); if (!(att.SizeHigh != 0 && att.SizeLow != 0)) { // Error MOG_REPORT.ShowMessageBox("Create Target Directory Path", string.Concat(RemapDirectoryString(targetPath), " could not be created!"), MessageBoxButtons.OK); return(false); } } } else { // Check if it already exists if (!DosUtils.FileExist(targetPath)) { // try { Directory.CreateDirectory(targetPath); } catch (Exception e) { // Error MOG_REPORT.ShowMessageBox("Create Directory Error", string.Concat(RemapDirectoryString(targetPath), " could not be created!", "\n", e.ToString()), MessageBoxButtons.OK); return(false); } } } return(true); }
public void ShowModuleNames() { List <string> moduleNames = XboxUtils.GetModuleNames(); foreach (string module in moduleNames) { Console.WriteLine(module); } }
private bool InitializeFileCounts() { bool success = true; mGetFileCount = true; mTotalFilesToCopy = 0; mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Data Sync", "Calculating total files to be copied:\nThis may take a few seconds...", ""); for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower()); string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot); string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower(); success = SyncDirectories(sourcePath, filePattern, mSyncRoot); mProgress.DialogUpdate((i * 100) / mPlatformSync.CountKeys("FileMap"), "Scanning:\n" + targetPath); Application.DoEvents(); // Create the needed directory on the xbox string newDirName = RemapDirectoryString(targetPath); if (mConsoleCopy) { if (!XboxUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } else { mPendingCopy.PutSectionString("DIR_EXISTS", newDirName); mPendingCopy.Save(); } } else { if (!DosUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } } // Check if the user has canceled if (!success) { throw new Exception("User canceled the opperation"); } } return(true); }
public bool FileExists(string filePath) { try { IXboxFile file = XboxUtils.GetFile(filePath); return(true); } catch (Exception) { XboxUtils.ErrorMessage(filePath + " does not exist."); return(false); } }
public bool Connect() { try { XboxUtils.Connect(); XboxUtils.ConfirmMessage("Successfully connected to console: " + XboxUtils.GetConsoleName()); return(true); } catch (Exception exception) { XboxUtils.ErrorMessage(exception.Message); return(false); } }
static void ModuleAction(ModuleCallBack moduleCallBack, string moduleName) { if (ModuleLoader.Connect()) { try { moduleCallBack(moduleName); } catch (Exception exception) { XboxUtils.ErrorMessage("An error occured. Full message: " + exception.Message); } ModuleLoader.Disconnect(); } }
public bool Disconnect() { if (!XboxUtils.IsConnected()) { return(true); } try { string consoleName = XboxUtils.GetConsoleName(); XboxUtils.Disconnect(); XboxUtils.ConfirmMessage("Successfully disconnected from console: " + consoleName); return(true); } catch (Exception exception) { XboxUtils.ErrorMessage(exception.Message); return(false); } }
public bool IsModuleLoaded(string moduleName) { try { List <string> modules = XboxUtils.GetModuleNames(); foreach (string module in modules) { if (moduleName.Contains(module)) { return(true); } } } catch (Exception exception) { XboxUtils.ErrorMessage(exception.Message); } return(false); }
private bool InitializeTimeStampMap() { // Get our target root string platformTimeStampsFile = string.Concat(mSourcePath, "\\MOG\\platform.", mMog.GetActivePlatform().mPlatformName, ".", Path.GetFileNameWithoutExtension(mTargetConsole), ".timestamps.info"); // Is this a force if (mForce) { if (DosUtils.FileExist(platformTimeStampsFile)) { DosUtils.FileDelete(platformTimeStampsFile); } if (mConsoleCopy) { // Delete the target directory on the xbox if (!XboxUtils.DirectoryDelete(mSyncRoot, true)) { // Error //MOG_REPORT.ShowMessageBox("Xbox Delete Error", string.Concat(mSyncRoot, " could not be deleted!"), MessageBoxButtons.OK); throw new Exception(mSyncRoot + " could not be deleted!"); } } else { if (!DosUtils.DirectoryDelete(mSyncRoot)) { //Error //MOG_REPORT.ShowMessageBox("Delete Error", string.Concat(mSyncRoot, " could not be deleted!"), MessageBoxButtons.OK); throw new Exception(mSyncRoot + " could not be deleted!"); } } } // Open the timestamp ini mTargetTimestamps = new MOG_Ini(platformTimeStampsFile); return(true); }
public void TargetXboxMakeLinearLoadIso() { // Optimize all the data string output = ""; string sourceDir = mainForm.mAssetManager.GetTargetPath(); string userName = mMog.GetUser().GetUserName(); bool useDefault = false; CallbackDialogForm bigProgress = new CallbackDialogForm(); bigProgress.DialogInitialize("Make Linear Load Build", "Creating linear maps...\nThis could take many hours", "Cancel"); // Use 'default' as user, if the Default checkbox is checked. This is used for the programmers who debug their code using the default.xbe if (mainForm.AssetManagerLocalDataXboxDefaultCheckBox.Checked) { userName = "******"; useDefault = true; } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } // Get the tool listed on the startup page string command = "[ProjectPath]\\Mog\\Tools\\Xbox\\Optimize\\Optimize.bat"; if (command.IndexOf("[ProjectPath]") != -1) { command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1)); } bigProgress.DialogUpdate(10, "Optimizing the newly merged data"); // Make sure the tool we need exits if (DosUtils.FileExist(command)) { // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } if (guiCommandLine.ShellExecute(command, mainForm.mAssetManager.GetTargetPath() + "\\System", ProcessWindowStyle.Normal, ref output) != 0) { MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK); } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } bigProgress.DialogUpdate(20, "Syncing to Build Xbox for linear load tool execution..."); // Sync to the Linear Build xbox string buildXbox = "LinearBuild"; // Logon to correct xbox XboxUtils.SetXboxName(buildXbox, false); guiPlatformSinc sinc = new guiPlatformSinc(buildXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false); sinc.mProjectSyncFile = "xbox.opt.ls.sync"; sinc.mUserSyncFile = ""; sinc.TargetConsoleSync(); // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } // Run the linear load tool string xboxExe = "xE:\\" + mMog.GetProject().GetProjectName() + "\\defaultls.xbe"; bigProgress.DialogUpdate(30, "Preparing for linear load tool execution..."); // Kill the Linear load complete file in the root before we call the tool if (XboxUtils.FileExist("xQ:\\LoadComplete.sys")) { XboxUtils.FileDelete("xQ:\\LoadComplete.sys"); } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } // Kill all previous linear files string LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\"); if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1) { CallbackDialogForm progress1 = new CallbackDialogForm(); progress1.DialogInitialize("Make Linear Load Build", "Deleting previous linear load maps...", "Cancel"); string [] files = LinearLoadFiles.Split(",".ToCharArray()); foreach (string file in files) { if (string.Compare(Path.GetExtension(file), ".lin", true) == 0) { progress1.DialogUpdate(0, file); XboxUtils.FileDelete(file); // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { progress1.DialogKill(); bigProgress.DialogKill(); return; } if (progress1.DialogProcess()) { progress1.DialogKill(); return; } } } progress1.DialogKill(); } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } MOG_Ini buttonDefaults = null; if (mMog.IsProject()) { // Get the project defaults string projectDefaultButtonsFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mMog.GetProject().GetProjectName() + ".Client.Buttons.Default.info"; if (DosUtils.FileExist(projectDefaultButtonsFile)) { buttonDefaults = new MOG_Ini(projectDefaultButtonsFile); } } // Get the tool listed on the startup page if (buttonDefaults != null) { if (buttonDefaults.SectionExist(mMog.GetProject().GetProjectName() + ".Buttons")) { if (buttonDefaults.KeyExist(mMog.GetProject().GetProjectName() + ".Buttons", "Run")) { command = buttonDefaults.GetString(mMog.GetProject().GetProjectName() + ".Buttons", "Run"); } } } if (command.IndexOf("[ProjectPath]") != -1) { command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1)); } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } bigProgress.DialogUpdate(50, "Starting the linear load creation tool..."); // Make sure the tool we need exits if (DosUtils.FileExist(command)) { if (guiCommandLine.ShellExecute(command, string.Concat("/x ", buildXbox, " ", xboxExe), ProcessWindowStyle.Hidden, ref output) != 0) { MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK); } // Wait till the LinearLoad.sys file exists before continuing... while (XboxUtils.FileExist("Q:\\LoadComplete.sys") == false) { Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } Thread.Sleep(500); } } else { MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK); } // Kill the Linear load complete file once we are done if (XboxUtils.FileExist("xQ:\\LoadComplete.sys")) { XboxUtils.FileDelete("xQ:\\LoadComplete.sys"); } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } bigProgress.DialogUpdate(80, "Retrieving linear load maps from Build Xbox..."); // Copy off the data LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\"); if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1) { CallbackDialogForm progress = new CallbackDialogForm(); progress.DialogInitialize("Make Linear Load Build", "Copying completed linear load maps...", "Cancel"); string [] files = LinearLoadFiles.Split(",".ToCharArray()); foreach (string file in files) { if (string.Compare(Path.GetExtension(file), ".lin", true) == 0) { string target = mMog.GetActivePlatform().mPlatformTargetPath + "\\xboxdata\\maps\\" + Path.GetFileName(file); progress.DialogUpdate(0, target); // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { progress.DialogKill(); bigProgress.DialogKill(); return; } if (progress.DialogProcess()) { progress.DialogKill(); break; } if (!XboxUtils.FileGet(file, target, false)) { MOG_REPORT.ShowMessageBox("Make Linear Load Build", "Error copying file(" + file + ") from build xbox!", MessageBoxButtons.OK); } } } progress.DialogKill(); } else { MOG_REPORT.ShowMessageBox("Make Linear Load Build", "There were no Linear Load files found on the Xbox Build machine(" + buildXbox + ")", MessageBoxButtons.OK); return; } // Check for user cancel Application.DoEvents(); if (bigProgress.DialogProcess()) { bigProgress.DialogKill(); return; } bigProgress.DialogUpdate(90, "Syncing to target Xbox..."); // Sync sinc = new guiPlatformSinc(mTargetXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false); sinc.mProjectSyncFile = "xbox.opt.ll.sync"; sinc.mUserSyncFile = ""; sinc.TargetConsoleSync(); } else { MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK); } bigProgress.DialogUpdate(100, "Done!"); bigProgress.DialogKill(); }
public void TargetConsoleRemoveSync() { // Build a list of exactly what should be on the xbox mGetFileCount = true; mTotalFilesToCopy = 0; bool success = true; string CopyFileMap = mSourcePath + "\\MOG\\platformSincMap." + mMog.GetActivePlatform().mPlatformName + ".info"; if (DosUtils.FileExist(CopyFileMap)) { if (!DosUtils.FileDelete(CopyFileMap)) { return; } } // Create the new map mPendingCopy = new MOG_Ini(CopyFileMap); InitializeFileMap(); mFileMapCreate = true; // Initialize our progress dialog mProgress = new CallbackDialogForm(); string message = "Preforming platform remove data Sync: \n" + " Project Sync file map:" + mProjectSyncFile + "\n" + " User Sync file map:" + mUserSyncFile + "\n"; mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Remove Data Sync", message, ""); Application.DoEvents(); for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower()); string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot); string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower(); success = SyncDirectories(sourcePath, filePattern, mSyncRoot); mProgress.DialogUpdate((i * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath); Application.DoEvents(); // Create the needed directory on the xbox string newDirName = RemapDirectoryString(targetPath); if (mConsoleCopy) { if (!XboxUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } } else { if (!DosUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } } } if (mConsoleCopy) { // Logon to correct xbox XboxUtils.SetXboxName(mTargetConsole, false); } mProgress.DialogInitialize("Sync Remove", "Scanning console for non-needed assets", ""); ArrayList deletableAssets = new ArrayList(); // Verify the xbox for each of these files for (int j = 0; j < mPlatformSync.CountKeys("FileMap"); j++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", j).ToLower()); string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot); string walkFiles = XboxUtils.GetFiles(targetPath + "\\"); mProgress.DialogUpdate((j * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath); Application.DoEvents(); if (walkFiles.Length != 0 && walkFiles.IndexOf(",") != -1) { string [] files = walkFiles.Split(",".ToCharArray()); for (int k = 0; k < files.Length; k++) { string targetFile = files[k]; if (Path.GetExtension(targetFile) != "") { // Check to see if this file exists in the map if (!mPendingCopy.KeyExist("MAP", targetFile)) { // Get the list of deletable assets deletableAssets.Add(targetFile); } } } } } mProgress.DialogKill(); mProgress = null; if (deletableAssets.Count != 0) { if (guiConfirmDialog.MessageBoxDialog("Console Remove Sync", "Is is OK to Delete the Following Assets?", deletableAssets, MessageBoxButtons.OKCancel) == DialogResult.OK) { // Delete the assets in the list from off the xbox foreach (string str in guiConfirmDialog.SelectedItems) { string [] parts = str.Split(",;".ToCharArray()); if (parts != null && parts.Length >= 2) { string assetDeleteName = parts[0]; XboxUtils.FileDelete(assetDeleteName); } } } } else { MOG_REPORT.ShowMessageBox("Sync Remove", "This target does not have any files that need to be deleted", MessageBoxButtons.OK); } }
public void TargetConsoleSync() { bool success = true; string summaryFile = ""; try { // Initialize our progress dialog mProgress = new CallbackDialogForm(); // Initialize our summery files for reporting what was copied summaryFile = InitializeSummaryMap(); // Initialize our file map to tell us what patterns to copy InitializeFileMap(); // Initialize a timestamp map to help us not copy over the same stuff every time InitializeTimeStampMap(); if (mConsoleCopy) { // Logon to correct xbox XboxUtils.SetXboxName(mTargetConsole, false); } // Create initial console directory InitializeTargetDirectory(); // Get the total number of files to be copied success = InitializeFileCounts(); string message = "Preforming platform data Sync: \n" + " Project Sync file map:" + mProjectSyncFile + "\n" + " User Sync file map:" + mUserSyncFile + "\n"; mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Data Sync", message, "Cancel"); Application.DoEvents(); // Walk the 'FileMap' and compare to our local game directory and sync to the Xbox if (success) { mGetFileCount = false; mFileNumber = 0; mProgress.CallbackDialogFilesProgressBar.Maximum = mTotalFilesToCopy + 2; // Walk the map file directories for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower()); string targetPath = ""; string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower(); if (RemapString(sourcePath, ref targetPath)) { success = SyncDirectories(sourcePath, filePattern, mSyncRoot); // Check if the user has canceled if (!success) { break; } } } } } catch (Exception e) { MOG_REPORT.ShowMessageBox("Console Sync", e.Message.ToString(), MessageBoxButtons.OK); } // Clean up our progress dialog if (mProgress != null) { mProgress.DialogKill(); mProgress.CallbackDialogFilesProgressBar.Maximum = 100; mProgress = null; } // Close and save the timestamps file if (mTargetTimestamps != null) { mTargetTimestamps.Save(); mTargetTimestamps.Close(); } // Close the platform.sinc.info if (mPlatformSync != null) { mPlatformSync.CloseNoSave(); } // Close the summary file if (mSummary != null) { mSummary.Save(); } // Check if we are supposed to launch the game after the sync if (mRunAfterSync) { RunXbox(); } // Show the update summary form if (mShowSummary) { UpdateBuildSummaryForm summary = new UpdateBuildSummaryForm(summaryFile); summary.ShowDialog(); } }
private bool SyncFile(string fullFilename, string targetFile) { bool rc = false; // Check for special rules for this asset in the ReMap section if (!RemapString(fullFilename, ref targetFile)) { return(false); } // Get the file FileInfo file = new FileInfo(fullFilename); bool fileExists = false; if (mConsoleCopy && !mFileMapCreate) { fileExists = XboxUtils.FileExist(targetFile); } else if (!mConsoleCopy && !mFileMapCreate) { fileExists = DosUtils.FileExist(targetFile); } else { fileExists = false; } if (fileExists && !mGetFileCount && mConsoleCopy) { // Check to see if the sizes of the source and target are the same uint targetSize = XboxUtils.GetFileSize(targetFile); uint sourceSize = (uint)file.Length; if (targetSize != sourceSize) { fileExists = false; } } // Check if the target file exists // If asset is in our timestamp file, it means we have already copied it once. We need to check if there is a timestamp difference // But if the asset does not even exist on the xbox we should force a copy if (fileExists && (mTargetTimestamps.SectionExist("ASSETS") && mTargetTimestamps.KeyExist("ASSETS", file.FullName)) ) { // Get timestamp of target and source // Copy if they are not the same if (string.Compare(file.LastWriteTime.ToFileTime().ToString(), mTargetTimestamps.GetString("ASSETS", file.FullName)) != 0) { if (mGetFileCount) { mTotalFilesToCopy++; mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile); mPendingCopy.Save(); } else { mProgress.DialogUpdate(mFileNumber++, string.Concat("Source: ", file.FullName, "\nTarget: ", targetFile)); Application.DoEvents(); if (mProgress.DialogProcess()) { return(false); } if (mConsoleCopy) { rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true); } else { rc = DosUtils.FileCopy(file.FullName, targetFile, true); } if (!rc) { mSummary.PutString("File.CopyError", file.FullName, targetFile); mSummary.Save(); // Check to see if the reason we failed is because we ran out of space // UInt64 freeSpace = XboxUtils.GetDiskFreeSpace(mSyncRoot); // if (freeSpace < (ulong)file.Length) // { // MOG_REPORT.ShowErrorMessageBox("Platform Sync: Out of space!", "There is insufficient space on " + mSyncRoot + " to copy " + file.FullName); // } } else { mSummary.PutString("File.Copied", file.FullName, targetFile); mSummary.Save(); mTargetTimestamps.PutString("ASSETS", file.FullName, file.LastWriteTime.ToFileTime().ToString()); mTargetTimestamps.Save(); } } } else { if (!mGetFileCount) { // This file is up to date mProgress.DialogUpdate(mFileNumber, string.Concat("FILE UP TO DATE! Skipping...\nSource: ", file.FullName)); Application.DoEvents(); // Check if the user cancels if (mProgress.DialogProcess()) { return(false); } } } } else { if (mGetFileCount) { mTotalFilesToCopy++; if (mFileMapCreate) { // When making a file map, put the target first then the source mPendingCopy.PutString("MAP", targetFile, file.FullName); } else { // When making a pending file, put the source first then target mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile); } //mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile); mPendingCopy.Save(); } else { mProgress.DialogUpdate(mFileNumber++, string.Concat("Source: ", file.FullName, "\nTarget: ", targetFile)); Application.DoEvents(); // Check if the user cancels if (mProgress.DialogProcess()) { return(false); } CreateTargetDirectoryPath(targetFile.Substring(0, targetFile.LastIndexOf("\\"))); // Sync the file to the platform try { if (mConsoleCopy) { rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true); } else { rc = DosUtils.FileCopy(file.FullName, targetFile, true); } //rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true); } catch (DllNotFoundException e) { MOG_REPORT.ShowMessageBox("DLL ERROR", e.ToString(), MessageBoxButtons.OK); return(false); } catch (EntryPointNotFoundException e) { MOG_REPORT.ShowMessageBox("DLL ERROR", e.ToString(), MessageBoxButtons.OK); return(false); } if (!rc) { // Error mSummary.PutString("File.CopyError", file.FullName, targetFile); mSummary.Save(); // Check to see if the reason we failed is because we ran out of space //UInt64 freeSpace = XboxUtils.GetDiskFreeSpace(mSyncRoot); //if (freeSpace < (ulong)file.Length) //{ // MOG_REPORT.ShowErrorMessageBox("Platform Sync: Out of space!", "There is insufficient space on " + mSyncRoot + " to copy " + file.FullName); //} } else { mSummary.PutString("File.Copied", file.FullName, targetFile); mSummary.Save(); mTargetTimestamps.PutString("ASSETS", file.FullName, file.LastWriteTime.ToFileTime().ToString()); mTargetTimestamps.Save(); } } } return(true); }
static void Main(string[] args) { if (args.Length == 0) { ModuleLoader.ShowHelp(); return; } if (args.Length > 2) { XboxUtils.ErrorMessage("Maximum number of arguments exceeded. ModuleLoader -h to see the usage."); return; } string firstArg = (args.Length > 0 && args[0] != null) ? args[0] : null; string secondArg = (args.Length > 1 && args[1] != null) ? args[1] : null; if (firstArg.StartsWith("-")) { switch (firstArg) { case "-h": ModuleLoader.ShowHelp(); break; case "-s": ModuleAction(Show, null); break; case "-l": if (secondArg != null) { ModuleAction(Load, secondArg); } else { XboxUtils.ErrorMessage("You need to specify an absolute module path. ModuleLoader -h to see the usage."); } break; case "-u": if (secondArg != null) { ModuleAction(Unload, secondArg); } else { XboxUtils.ErrorMessage("You need to specify an absolute module path. ModuleLoader -h to see the usage."); } break; default: XboxUtils.ErrorMessage(firstArg + " is not a valid argument. ModuleLoader -h to see the usage."); break; } } else { if (secondArg != null) { XboxUtils.ErrorMessage("You can not specify argument after the module path. ModuleLoader -h to see the usage."); } else { ModuleAction(UnloadThenLoad, firstArg); } } }