@ -5,6 +5,7 @@
# include <iostream>
# include <iostream>
# include <string>
# include <string>
# include <chrono>
# include <chrono>
# include <sstream>
//typedef std::std::byte std::byte;
//typedef std::std::byte std::byte;
typedef char sbyte ;
typedef char sbyte ;
@ -16,7 +17,7 @@ class SHNFile{
int ReadInt32 ( std : : ifstream & file ) ;
int ReadInt32 ( std : : ifstream & file ) ;
void Encrypt ( ) ;
void Encrypt ( ) ;
void Decrypt ( ) ;
void Decrypt ( ) ;
std : : vector < std : : byte > ReadBytes ( int bytes ) ;
std : : vector < std : : byte > & ReadBytes ( int bytes ) ;
std : : byte ReadByte ( ) ;
std : : byte ReadByte ( ) ;
void WriteByte ( std : : ofstream & f , std : : byte b ) ;
void WriteByte ( std : : ofstream & f , std : : byte b ) ;
void WriteSByte ( std : : ofstream & f , sbyte b ) ;
void WriteSByte ( std : : ofstream & f , sbyte b ) ;
@ -146,13 +147,13 @@ std::vector<std::byte>&SHNFile::ReadBytes(int bytes){
readArr . clear ( ) ;
readArr . clear ( ) ;
for ( int i = 0 ; i < bytes ; i + + ) {
for ( int i = 0 ; i < bytes ; i + + ) {
if ( marker < data . size ( ) ) {
if ( marker < data . size ( ) ) {
byte Arr. push_back ( data [ marker ] ) ;
read Arr. push_back ( data [ marker ] ) ;
marker + + ;
marker + + ;
} else {
} else {
break ;
break ;
}
}
}
}
return byte Arr;
return read Arr;
}
}
std : : byte SHNFile : : ReadByte ( ) {
std : : byte SHNFile : : ReadByte ( ) {
std : : vector < std : : byte > & b = ReadBytes ( 1 ) ;
std : : vector < std : : byte > & b = ReadBytes ( 1 ) ;
@ -341,8 +342,6 @@ std::string SHNFile::Data::GetDisplayText(){
}
}
}
}
void SHNFile : : Load ( std : : string file ) {
void SHNFile : : Load ( std : : string file ) {
cryptHeader . clear ( ) ;
data . clear ( ) ;
header = recordCount = defaultRecordLength = columnCount = 0 ;
header = recordCount = defaultRecordLength = columnCount = 0 ;
columns . clear ( ) ;
columns . clear ( ) ;
contents . 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.
//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.
//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 ) ;
cryptHeader = ReadBytes ( f , 0x20 ) ;
std : : copy ( cryptHeader . begin ( ) , cryptHeader . end ( ) , std : : back_inserter ( rawData ) ) ;
int readAmt = ReadInt32 ( f ) ;
int readAmt = ReadInt32 ( f ) ;
rawData . push_back ( std : : byte ( readAmt & 0xFF ) ) ;
rawData . push_back ( std : : byte ( readAmt & 0xFF ) ) ;
rawData . push_back ( std : : byte ( ( readAmt > > 8 ) & 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 ) {
void SHNFile : : Write ( int row , int col , std : : string val ) {
contents [ row ] [ col ] . Set < std : : string > ( val ) ;
contents [ row ] [ col ] . Set < std : : string > ( val ) ;
}
}
SHNFile : : SHNFile ( ) { }
SHNFile : : SHNFile ( ) {
readArr . reserve ( 64000 ) ;
}
# endif
# endif