예제 #1
0
        private void Save(Project project, string filename, ProjectSerializer serializer)
        {
            var data = DoSave(project, filename, serializer);

            File.WriteAllBytes(filename, data);
            project.UnsavedChanges  = false;
            project.ProjectFileName = filename;
        }
예제 #2
0
        private byte[] DoSave(Project project, string filename, ProjectSerializer serializer)
        {
            var data = serializer.Save(project);

            if (!IsUncompressedProject(filename))
            {
                data = Util.TryZip(data);
            }

            return(data);
        }
예제 #3
0
        private byte[] DoSave(Project project, string filename, ProjectSerializer serializer)
        {
            var data = SerializeWith(project, serializer);

            if (IsLikelyCompressed(filename))
            {
                data = Util.TryZip(data);
            }

            return(data);
        }
예제 #4
0
        private void Save(Project project, string filename, ProjectSerializer serializer)
        {
            var data = DoSave(project, filename, serializer);

            WriteBytes(filename, data);

            if (project.Session != null)
            {
                project.Session.UnsavedChanges  = false;
                project.Session.ProjectFileName = filename;
            }
        }
예제 #5
0
        private void PostSerialize(string filename, ProjectXmlSerializer.Root xmlRoot, ProjectSerializer serializer)
        {
            if (xmlRoot?.Project?.Data?.SnesAddressSpace != null || xmlRoot?.Project?.Session == null)
            {
                throw new InvalidDataException(
                          "Internal error with deserialized data, either Project, Data, Session, or SnesAddressSpace failed to load correctly.");
            }

            xmlRoot.Project.Session = new ProjectSession(xmlRoot.Project)
            {
                ProjectFileName = filename
            };

            // at this stage, 'Data' is populated with everything EXCEPT the actual ROM bytes.
            // It would be easy to store the ROM bytes in the save file, but, for copyright reasons,
            // we leave it out.
            //
            // So now, with all our metadata loaded successfully, we now open the .smc file on disk
            // and marry the original rom's bytes with all of our metadata loaded from the project file.

            var romAddCmd = new AddRomDataCommand(xmlRoot)
            {
                GetNextRomFileToTry = RomPromptFn,
                MigrationRunner     = serializer.MigrationRunner,
            };

            romAddCmd.TryReadAttachedProjectRom();
        }
예제 #6
0
 protected virtual (ProjectXmlSerializer.Root xmlRoot, string warning) DeserializeWith(
     ProjectSerializer serializer, byte[] rawBytes
     ) => serializer.Load(rawBytes);