@ -5,6 +5,7 @@
# include <iostream>
# include <string>
# include <chrono>
# include <sstream>
//typedef std::std::byte std::byte;
typedef char sbyte ;
@ -16,7 +17,7 @@ class SHNFile{
int ReadInt32 ( std : : ifstream & file ) ;
void Encrypt ( ) ;
void Decrypt ( ) ;
std : : vector < std : : byte > ReadBytes ( int bytes ) ;
std : : vector < std : : byte > & ReadBytes ( int bytes ) ;
std : : byte ReadByte ( ) ;
void WriteByte ( std : : ofstream & f , std : : byte b ) ;
void WriteSByte ( std : : ofstream & f , sbyte b ) ;
@ -146,13 +147,13 @@ std::vector<std::byte>&SHNFile::ReadBytes(int bytes){
readArr . clear ( ) ;
for ( int i = 0 ; i < bytes ; i + + ) {
if ( marker < data . size ( ) ) {
byte Arr. push_back ( data [ marker ] ) ;
read Arr. push_back ( data [ marker ] ) ;
marker + + ;
} else {
break ;
}
}
return byte Arr;
return read Arr;
}
std : : byte SHNFile : : ReadByte ( ) {
std : : vector < std : : byte > & b = ReadBytes ( 1 ) ;
@ -341,8 +342,6 @@ std::string SHNFile::Data::GetDisplayText(){
}
}
void SHNFile : : Load ( std : : string file ) {
cryptHeader . clear ( ) ;
data . clear ( ) ;
header = recordCount = defaultRecordLength = columnCount = 0 ;
columns . clear ( ) ;
contents . clear ( ) ;
@ -356,7 +355,6 @@ void SHNFile::Load(std::string file){
//Since we don't just read in the entire file raw, we have to do some additional work here as the header provides us with some basic info on how to decrypt this file.
//The backup itself needs all the data from the original file, so we're appending it to rawData as we continue reading it.
cryptHeader = ReadBytes ( f , 0x20 ) ;
std : : copy ( cryptHeader . begin ( ) , cryptHeader . end ( ) , std : : back_inserter ( rawData ) ) ;
int readAmt = ReadInt32 ( f ) ;
rawData . push_back ( std : : byte ( readAmt & 0xFF ) ) ;
rawData . push_back ( std : : byte ( ( readAmt > > 8 ) & 0xFF ) ) ;
@ -537,5 +535,7 @@ void SHNFile::Write(int row,int col,float val){
void SHNFile : : Write ( int row , int col , std : : string val ) {
contents [ row ] [ col ] . Set < std : : string > ( val ) ;
}
SHNFile : : SHNFile ( ) { }
SHNFile : : SHNFile ( ) {
readArr . reserve ( 64000 ) ;
}
# endif