Ejemplo n.º 1
0
 public virtual void LoadFile()
 {
     Log.Debug("Loading File Data [ {0} ]", FileTargetPath);
     FileData = File.ReadAllBytes(FileTargetPath);
     Log.Debug("File [ {0} ] Loaded Into Patcher Successfully", FileTargetPath);
     FilesToBackup.Add(FileTargetPath);
 }
Ejemplo n.º 2
0
        public static void CreateDemoRequiredFiles()
        {
            BackupFiles objBackupFiles;
            BackupFile objBackupFile;
            FilesToBackup objFilesToBackup;
            FileToBackUp objFileToBackup;
            SingleFileToBackUp objSingleFileToBackup;

            //Procedure for reading file from tape; Backup files must have a Size, NewFileName, FilePath and StartTapeLocation to be restored
            objBackupFiles = new BackupFiles();
            objBackupFile = new BackupFile { StartTapeLocation = 0, EndTapeLocation = 84673, FilePath = Directory.GetCurrentDirectory() + "\\", FileName = "Test1.txt", Size = 5549095658 };
            objBackupFiles.Add(objBackupFile);
            objBackupFile = new BackupFile { StartTapeLocation = 84673, EndTapeLocation = 84990, FilePath = Directory.GetCurrentDirectory() + "\\", FileName = "Test2.txt", Size = 20764304 };
            objBackupFiles.Add(objBackupFile);
            objBackupFiles.SaveToXMLFile(Directory.GetCurrentDirectory() + "\\", "BackedUpFilesExample.xml");

            //Backup files must have a FilePath and FileName in order to be written to the tape; StartTapeLocation is required when writing a single file,
            //otherwise the app assigns locations as it's backing up multiple files
            objFilesToBackup = new FilesToBackup();
            objFileToBackup = new FileToBackUp { FilePath = Directory.GetCurrentDirectory() + "\\", FileName = "Test1.txt" };
            objFilesToBackup.Add(objFileToBackup);
            objFileToBackup = new FileToBackUp { FilePath = Directory.GetCurrentDirectory() + "\\", FileName = "Test2.txt" };
            objFilesToBackup.Add(objFileToBackup);
            objFilesToBackup.SaveToXMLFile(Directory.GetCurrentDirectory() + "\\", "FilesToBackupExample.xml");

            objSingleFileToBackup = new SingleFileToBackUp { StartTapeLocation = 84673, FilePath = Directory.GetCurrentDirectory() + "\\", FileName = "Test2.txt" };
            objSingleFileToBackup.Serialize(Directory.GetCurrentDirectory() + "\\FileToBackupExample.xml");
        }
Ejemplo n.º 3
0
        public override void LoadFile()
        {
            //base.LoadFile();
            Log.Debug("Loading UPK File Data [ {0} ]", FileTargetPath);
            var uncompressedUpkFilePath = XCOMUtilities.DecompressUPKFile(UPKDecompressDirectory, FileTargetPath);

            // Check for uncompressed_size
            var uncompressedSizeFilePath = string.Format("{0}.uncompressed_size", FileTargetPath);

            Log.Debug("Checking for uncompressed_size [ {0} ]", uncompressedSizeFilePath);
            if (File.Exists(uncompressedSizeFilePath))
            {
                Log.Debug("uncompressed_size [ {0} ] file exists", uncompressedSizeFilePath);
                FilesToBackup.Add(uncompressedSizeFilePath);
                HasUncompressedSizeFile = true;
            }


            FileData = File.ReadAllBytes(uncompressedUpkFilePath);
            Log.Debug("File [ {0} ] Loaded Into Patcher Successfully", FileTargetPath);
            FilesToBackup.Add(FileTargetPath);
        }
Ejemplo n.º 4
0
        private static void BackupFiles(string strFilesToBackupFilePathAndName)
        {
            FilesToBackup objFilesToBackup;

            try
            {
                using (StreamWriter w = File.CreateText("log.txt"))
                {
                    Log(string.Format("Backup Operation Started at {0}", DateTime.Now), w);
                    // Close the writer and underlying file.
                    w.Close();
                }

                objFilesToBackup = new FilesToBackup(Path.GetDirectoryName(strFilesToBackupFilePathAndName) + "\\", Path.GetFileName(strFilesToBackupFilePathAndName));
                BackupFileList = objFilesToBackup.ToBackupFiles();

                Backup.WriteFilesToTape(BackupFileList);
                BackupFileList.SaveToXMLFile(Directory.GetCurrentDirectory() + "\\", "BackedUpFiles.xml");

                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    Log(string.Format("Backup Operation Ended at {0}", DateTime.Now), w);
                    // Close the writer and underlying file.
                    w.Close();
                }
            }
            catch (Exception objEx)
            {
                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    Log(string.Format("Error {0}", objEx.ToString()), w);
                    // Close the writer and underlying file.
                    w.Close();
                }
            }
        }
Ejemplo n.º 5
0
        public static void MakeBackup(bool[] states)
        {
            List <files> FilesToBackup;

            try
            {
                FilesToBackup = logic.files.GetFiles();
                if (FilesToBackup.Count == 0)
                {
                    new logs.log().WriteLog(3, "There are no files in files.txt");
                }
            }
            catch (Exception)
            {
                new logs.log().WriteLog(3, "Files.txt not found");
                return;
            }

            bool resourcepack     = states[0];
            bool saves            = states[1];
            bool launcherprofiles = states[2];
            bool options          = states[3];
            bool screenshots      = states[4];
            bool logs             = states[5];


            foreach (files f in FilesToBackup)
            {
                if (!resourcepack)
                {
                    if (f.path.Contains("resourcepacks"))
                    {
                        FilesToBackup.Remove(f);
                    }
                }
                if (!saves)
                {
                    if (f.path.Contains("saves"))
                    {
                        FilesToBackup.Remove(f);
                    }
                }
                if (!launcherprofiles)
                {
                    if (f.path.Contains("launcher_profiles"))
                    {
                        FilesToBackup.Remove(f);
                    }
                }
                if (!options)
                {
                    if (f.path.Contains("options.txt"))
                    {
                        FilesToBackup.Remove(f);
                    }
                }
                if (!screenshots)
                {
                    if (f.path.Contains("screenshots"))
                    {
                        FilesToBackup.Remove(f);
                    }
                }
            }

            try
            {
                new logs.log().WriteLog(0, "Starting backup at " + DateTime.Now);
                Backup(FilesToBackup);
            }
            catch (Exception)
            {
                new logs.log().WriteLog(3, "Error while doing backup");
            }
        }