示例#1
0
        internal string GetSavePath(ServiceCtx context, SaveInfo saveInfo, bool isDirectory = true)
        {
            string saveUserPath   = "";
            string baseSavePath   = NandPath;
            ulong  currentTitleId = saveInfo.TitleId;

            switch (saveInfo.SaveSpaceId)
            {
            case SaveSpaceId.NandUser:   baseSavePath = UserNandPath;                         break;

            case SaveSpaceId.NandSystem: baseSavePath = SystemNandPath;                       break;

            case SaveSpaceId.SdCard:     baseSavePath = Path.Combine(SdCardPath, "Nintendo"); break;
            }

            baseSavePath = Path.Combine(baseSavePath, "save");

            if (saveInfo.TitleId == 0 && saveInfo.SaveDataType == SaveDataType.SaveData)
            {
                currentTitleId = context.Process.TitleId;
            }

            if (saveInfo.SaveSpaceId == SaveSpaceId.NandUser)
            {
                saveUserPath = saveInfo.UserId.IsNull ? "savecommon" : saveInfo.UserId.ToString();
            }

            string savePath = Path.Combine(baseSavePath,
                                           saveInfo.SaveId.ToString("x16"),
                                           saveUserPath,
                                           saveInfo.SaveDataType == SaveDataType.SaveData ? currentTitleId.ToString("x16") : string.Empty);

            return(MakeFullPath(savePath, isDirectory));
        }
示例#2
0
        public static IFileSystem OpenSystemSaveData(ServiceCtx context, ulong saveId)
        {
            SaveInfo saveInfo = new SaveInfo(0, (long)saveId, SaveDataType.SystemSaveData, SaveSpaceId.NandSystem);
            string   savePath = context.Device.FileSystem.GetSavePath(context, saveInfo, false);

            if (File.Exists(savePath))
            {
                string tempDirectoryPath = $"{savePath}_temp";

                Directory.CreateDirectory(tempDirectoryPath);

                IFileSystem outputFolder = new LocalFileSystem(tempDirectoryPath);

                using (LocalStorage systemSaveData = new LocalStorage(savePath, FileAccess.Read, FileMode.Open))
                {
                    IFileSystem saveFs = new LibHac.FsSystem.Save.SaveDataFileSystem(context.Device.System.KeySet, systemSaveData, IntegrityCheckLevel.None, false);

                    saveFs.CopyDirectory(outputFolder, "/", "/");
                }

                File.Delete(savePath);

                Directory.Move(tempDirectoryPath, savePath);
            }
            else
            {
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
            }

            return(new LocalFileSystem(savePath));
        }
示例#3
0
        public static string GetSavePath(SaveInfo SaveMetaData, ServiceCtx Context)
        {
            string BaseSavePath   = NandPath;
            long   CurrentTitleId = SaveMetaData.TitleId;

            switch (SaveMetaData.SaveSpaceId)
            {
            case SaveSpaceId.NandUser:
                BaseSavePath = UserNandPath;
                break;

            case SaveSpaceId.NandSystem:
                BaseSavePath = SystemNandPath;
                break;

            case SaveSpaceId.SdCard:
                BaseSavePath = Path.Combine(SdCardPath, "Nintendo");
                break;
            }

            BaseSavePath = Path.Combine(BaseSavePath, "save");

            if (SaveMetaData.TitleId == 0 && SaveMetaData.SaveDataType == SaveDataType.SaveData)
            {
                if (Context.Process.MetaData != null)
                {
                    CurrentTitleId = Context.Process.MetaData.ACI0.TitleId;
                }
            }

            string SaveAccount = SaveMetaData.UserId.IsZero() ? "savecommon" : SaveMetaData.UserId.ToString();

            string SavePath = Path.Combine(BaseSavePath,
                                           SaveMetaData.SaveId.ToString("x16"),
                                           SaveAccount,
                                           SaveMetaData.SaveDataType == SaveDataType.SaveData ? CurrentTitleId.ToString("x16") : string.Empty);

            return(SavePath);
        }
示例#4
0
        public static string GetSavePath(SaveInfo saveMetaData, ServiceCtx context)
        {
            string baseSavePath   = NandPath;
            long   currentTitleId = saveMetaData.TitleId;

            switch (saveMetaData.SaveSpaceId)
            {
            case SaveSpaceId.NandUser:
                baseSavePath = UserNandPath;
                break;

            case SaveSpaceId.NandSystem:
                baseSavePath = SystemNandPath;
                break;

            case SaveSpaceId.SdCard:
                baseSavePath = Path.Combine(SdCardPath, "Nintendo");
                break;
            }

            baseSavePath = Path.Combine(baseSavePath, "save");

            if (saveMetaData.TitleId == 0 && saveMetaData.SaveDataType == SaveDataType.SaveData)
            {
                currentTitleId = context.Process.TitleId;
            }

            string saveAccount = saveMetaData.UserId.IsNull ? "savecommon" : saveMetaData.UserId.ToString();

            string savePath = Path.Combine(baseSavePath,
                                           saveMetaData.SaveId.ToString("x16"),
                                           saveAccount,
                                           saveMetaData.SaveDataType == SaveDataType.SaveData ? currentTitleId.ToString("x16") : string.Empty);

            return(savePath);
        }
示例#5
0
 public string GetGameSavePath(SaveInfo Save, ServiceCtx Context)
 {
     return(MakeDirAndGetFullPath(SaveHelper.GetSavePath(Save, Context)));
 }