Ejemplo n.º 1
0
        public string[] GetListOfBackedUpSaves(Constants.GameChoice gameChoice)
        {
            // Use the AppData location to get a list of backed up saves
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string myPath  = "";

            switch (gameChoice)
            {
            case Constants.GameChoice.FarCry5:
                myPath = appData + @"\" + Constants.SystemFolderPaths.APPDATA_FOLDER_FC5;
                break;

            case Constants.GameChoice.FarCryNewDawn:
                myPath = appData + @"\" + Constants.SystemFolderPaths.APPDATA_FOLDER_FCND;
                break;
            }

            if (Directory.Exists(myPath))
            {
                return(Directory.GetDirectories(myPath));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        // Public methods
        //---------------------------------

        public void UpdateStorefrontSubfolder(Constants.Storefront storefront, Constants.GameChoice gameChoice)
        {
            switch (gameChoice)
            {
            case Constants.GameChoice.FarCry5:
            {
                if (storefront == Constants.Storefront.Steam)
                {
                    storefrontSubFolder = Constants.GameIDs.FC5_STEAM_GAME_ID;
                }
                else
                {
                    storefrontSubFolder = Constants.GameIDs.FC5_UPLAY_GAME_ID;
                }
                break;
            }

            case Constants.GameChoice.FarCryNewDawn:
            {
                if (storefront == Constants.Storefront.Steam)
                {
                    storefrontSubFolder = Constants.GameIDs.FCND_STEAM_GAME_ID;
                }
                else
                {
                    storefrontSubFolder = Constants.GameIDs.FCND_UPLAY_GAME_ID;
                }
                break;
            }
            }
        }
Ejemplo n.º 3
0
 public void UpdateStorefront(Constants.Storefront storefront, Constants.GameChoice gameChoice)
 {
     saveFileSystemManager.UpdateStorefrontSubfolder(storefront, gameChoice);
 }
Ejemplo n.º 4
0
        public bool BackupSave(string idSaveDir, string title, Constants.GameChoice gameChoice)
        {
            string direc = "";

            try
            {
                // Generate the Appdata folder where we save our backups
                string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                string myPath  = "";

                switch (gameChoice)
                {
                case Constants.GameChoice.FarCry5:
                    myPath = appData + @"\" + Constants.SystemFolderPaths.APPDATA_FOLDER_FC5;
                    break;

                case Constants.GameChoice.FarCryNewDawn:
                    myPath = appData + @"\" + Constants.SystemFolderPaths.APPDATA_FOLDER_FCND;
                    break;
                }


                if (!Directory.Exists(myPath))
                {
                    Directory.CreateDirectory(myPath);
                }

                //Make a super-wicked-cool-time-based-unique save folder name
                DateTime date    = DateTime.Now;
                String   timeStr = date.ToString("HH:mm:ss.fff");
                String   dateStr = date.ToString("MM/dd/yyyy");
                //remove characters filenames don't like
                timeStr = timeStr.Replace(':', '_');
                dateStr = dateStr.Replace('/', '_');
                String folderName = storefrontSubFolder + "_" + dateStr + "_" + timeStr;
                folderName = folderName.Replace(" ", "");

                // Create folder and save path for deletion upon failure
                string backupLocation = myPath + @"\" + title + folderName;
                Directory.CreateDirectory(backupLocation);
                direc = backupLocation;

                // Copy the files to backup location
                string        sourceDir = idSaveDir + @"\" + storefrontSubFolder;
                DirectoryInfo dirInfo   = new DirectoryInfo(sourceDir);
                FileInfo[]    files     = dirInfo.GetFiles();

                foreach (var file in files)
                {
                    file.CopyTo(backupLocation + @"\" + file.Name, false);
                }

                OnBackupsUpdated();
                return(true);
            }
            catch (IOException)
            {
                //delete the failed directory if it was created
                if (direc != "")
                {
                    Directory.Delete(direc);
                }

                return(false);
            }
        }