Esempio n. 1
0
		public static void SaveData( ShaiyaData Data, string SavePath ) {
			string baseSavePath = Path.GetDirectoryName( SavePath );
			string nameSavePath = Path.GetFileNameWithoutExtension( SavePath );
			string tempPrefix = "__tmp__";
			SavePath = baseSavePath + @"\" + tempPrefix + nameSavePath;

			// save File Data (updates offsets)
			using( FileStream fs = File.OpenWrite( SavePath + ".saf" ) )
				WriteFileData( fs, Data );

			// save Header File (with new offsets)
			using( FileStream fs = File.OpenWrite( SavePath + ".sah" ) ) {
				WriteHead( fs );
				WriteFileStructure( fs, Data.Files );
			}


			// remove tmpPrefix, delete existing Files & rename tmp's
			string newSavePath = SavePath.Replace( tempPrefix, "" );
			if( File.Exists( newSavePath + ".sah" ) )
				File.Delete( newSavePath + ".sah" );
			if( File.Exists( newSavePath + ".saf" ) )
				File.Delete( newSavePath + ".saf" );

			File.Move( SavePath + ".sah", newSavePath + ".sah" );
			File.Move( SavePath + ".saf", newSavePath + ".saf" );

			if( OnWriteFile != null )
				OnWriteFile( null, 100 );
		}
Esempio n. 2
0
        private static void WriteFileData(FileStream fs, ShaiyaData Data)
        {
            foreach (ShaiyaDataEntry Entry in Data.FilesFlat.Values)
            {
                if (Entry.IsDir)
                {
                    continue;
                }

                if (Entry.Buffer == null)                  // not changed or new
                {
                    continue;
                }

                if (OnWriteFile != null)
                {
                    OnWriteFile(Entry, 0);
                }

                System.Diagnostics.Debug.WriteLine("[updated] " + Entry.Filename);

                fs.Seek(Entry.Offset, SeekOrigin.Begin);
                fs.Write(Entry.Buffer, 0, Entry.Buffer.Length);

                Data.FilesFlat[Entry.ID].Buffer = null;                   // updated
            }

            System.Diagnostics.Debug.WriteLine("saving done");
        }
        private static void WriteFileData(FileStream fs, ShaiyaData Data)
        {
            byte[] buf;
            int    i = 0;

            foreach (ShaiyaDataEntry Entry in Data.FilesFlat.Values)
            {
                if (Entry.IsDir)
                {
                    i++;
                    continue;
                }

                if (OnWriteFile != null)
                {
                    OnWriteFile(Entry, i);
                }

                if (Data.GetData(Entry, out buf) == false || buf == null || buf.Length == 0)
                {
                    i++;
                    continue;
                }

                // update new Offset
                Data[Entry.ID].Offset = fs.Position;
                fs.Write(buf, 0, buf.Length);

                buf = null;
                i++;
            }
        }
Esempio n. 4
0
		public static void Main( string[] args ) {
			string[] dirs = Directory.GetDirectories( @"D:\Spiele\Shaiya Copy\patches\" );
			foreach( string dir in dirs ) {
				string subdir = dir.Substring( dir.LastIndexOf( '\\' ) +1 );
				Console.Write( "parse dir " + subdir + "..." );

				if( File.Exists( dir + @"\update.sah" ) == false ) {
					Console.WriteLine( "\n\tNO DATA FOUND - delete dir..." );
					Directory.Delete( dir );
					continue;
				}

				ShaiyaData data = new ShaiyaData( dir + @"\update.sah" );
				if( data.ExtractAll( dir ) == false ) {
					Console.WriteLine( "\n\tfailed to extract Data or some of the Files.. abort deleting" );
					data.Dispose();
					continue;
				}
				Console.WriteLine( " extracted " + data.Files.Count + " Files" );
				data.Dispose();

				// delte update Files
				File.Delete( dir + @"\update.sah" );
				File.Delete( dir + @"\update.saf" );
			}

			Console.WriteLine( "\n\nfinished" );
			Console.ReadKey();

		}
Esempio n. 5
0
		public frmRepack( EPackType PackType, string SavePath, ShaiyaData Data ) {
			InitializeComponent();

			mPackType = PackType;
			if( mPackType == EPackType.SaveUpdates )
				this.Text = "Daten speichern...";
			else
				this.Text = "Daten neu packen...";

			mSavePath = SavePath;
			mData = Data;
		}
Esempio n. 6
0
        public frmRepack(EPackType PackType, string SavePath, ShaiyaData Data)
        {
            InitializeComponent();

            mPackType = PackType;
            if (mPackType == EPackType.SaveUpdates)
            {
                this.Text = "Daten speichern...";
            }
            else
            {
                this.Text = "Daten neu packen...";
            }

            mSavePath = SavePath;
            mData     = Data;
        }
Esempio n. 7
0
		public static void SaveData( ShaiyaData Data ) {
			// delete Header, we rewrite it
			if( File.Exists( Data.BasePath + ".sah" ) )
				File.Delete( Data.BasePath + ".sah" );

			// save Header File
			using( FileStream fs = File.OpenWrite( Data.BasePath + ".sah" ) ) {
				WriteHead( fs );
				WriteFileStructure( fs, Data.Files );
			}

			// save new/updated File Data
			using( FileStream fs = File.OpenWrite( Data.BasePath + ".saf" ) )
				WriteFileData( fs, Data );

			if( OnWriteFile != null )
				OnWriteFile( null, 100 );
		}
Esempio n. 8
0
		private static void WriteFileData( FileStream fs, ShaiyaData Data ) {
			foreach( ShaiyaDataEntry Entry in Data.FilesFlat.Values ) {
				if( Entry.IsDir ) 
					continue;

				if( Entry.Buffer == null ) // not changed or new
					continue;

				if( OnWriteFile != null )
					OnWriteFile( Entry, 0 );

				System.Diagnostics.Debug.WriteLine( "[updated] " + Entry.Filename );

				fs.Seek( Entry.Offset, SeekOrigin.Begin );
				fs.Write( Entry.Buffer, 0, Entry.Buffer.Length );

				Data.FilesFlat[ Entry.ID ].Buffer = null; // updated
			}

			System.Diagnostics.Debug.WriteLine( "saving done" );
		}
        public static void SaveData(ShaiyaData Data, string SavePath)
        {
            string baseSavePath = Path.GetDirectoryName(SavePath);
            string nameSavePath = Path.GetFileNameWithoutExtension(SavePath);
            string tempPrefix   = "__tmp__";

            SavePath = baseSavePath + @"\" + tempPrefix + nameSavePath;

            // save File Data (updates offsets)
            using (FileStream fs = File.OpenWrite(SavePath + ".saf"))
                WriteFileData(fs, Data);

            // save Header File (with new offsets)
            using (FileStream fs = File.OpenWrite(SavePath + ".sah")) {
                WriteHead(fs);
                WriteFileStructure(fs, Data.Files);
            }


            // remove tmpPrefix, delete existing Files & rename tmp's
            string newSavePath = SavePath.Replace(tempPrefix, "");

            if (File.Exists(newSavePath + ".sah"))
            {
                File.Delete(newSavePath + ".sah");
            }
            if (File.Exists(newSavePath + ".saf"))
            {
                File.Delete(newSavePath + ".saf");
            }

            File.Move(SavePath + ".sah", newSavePath + ".sah");
            File.Move(SavePath + ".saf", newSavePath + ".saf");

            if (OnWriteFile != null)
            {
                OnWriteFile(null, 100);
            }
        }
Esempio n. 10
0
        public static void SaveData(ShaiyaData Data)
        {
            // delete Header, we rewrite it
            if (File.Exists(Data.BasePath + ".sah"))
            {
                File.Delete(Data.BasePath + ".sah");
            }

            // save Header File
            using (FileStream fs = File.OpenWrite(Data.BasePath + ".sah")) {
                WriteHead(fs);
                WriteFileStructure(fs, Data.Files);
            }

            // save new/updated File Data
            using (FileStream fs = File.OpenWrite(Data.BasePath + ".saf"))
                WriteFileData(fs, Data);

            if (OnWriteFile != null)
            {
                OnWriteFile(null, 100);
            }
        }
Esempio n. 11
0
		private static void WriteFileData( FileStream fs, ShaiyaData Data ) {
			byte[] buf;
			int i = 0;
			foreach( ShaiyaDataEntry Entry in Data.FilesFlat.Values ) {
				if( Entry.IsDir ) {
					i++;
					continue;
				}

				if( OnWriteFile != null )
					OnWriteFile( Entry, i );

				if( Data.GetData( Entry, out buf ) == false || buf == null || buf.Length == 0 ) {
					i++;
					continue;
				}

				// update new Offset
				Data[ Entry.ID ].Offset = fs.Position;
				fs.Write( buf, 0, buf.Length );

				buf = null;
				i++;
			}

		}