mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@367 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e764723832
commit
8a33d6787b
@ -86,6 +86,50 @@ bool ChunkFile::Do(void *ptr, int size)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Do variable size array (probably heap-allocated)
|
||||
bool DoArray(void *ptr, int size, int arrSize) {
|
||||
int sz;
|
||||
|
||||
if(ptr == NULL)
|
||||
return false;
|
||||
|
||||
switch (mode) {
|
||||
case MODE_READ:
|
||||
sz = ReadInt();
|
||||
if (sz != size)
|
||||
return false;
|
||||
sz = ReadInt();
|
||||
if (sz != arrSize)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < arrSize; i++) {
|
||||
fread(ptr[i], size, 1, f);
|
||||
fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
||||
}
|
||||
break;
|
||||
case MODE_WRITE:
|
||||
WriteInt(size);
|
||||
WriteInt(arrSize);
|
||||
for(int i = 0; i < arrSize; i++) {
|
||||
fwrite(ptr[i], size, 1, f);
|
||||
fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
||||
}
|
||||
break;
|
||||
case MODE_VERIFY:
|
||||
sz = ReadInt();
|
||||
if (sz != size)
|
||||
return false;
|
||||
sz = ReadInt();
|
||||
if (sz != arrSize)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < arrSize; i++)
|
||||
fseek(f, (size + 3) & ~3, SEEK_CUR);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//let's get into the business
|
||||
bool ChunkFile::Descend(const char *cid)
|
||||
{
|
||||
|
@ -81,25 +81,34 @@ public:
|
||||
//bool Do(std::string &s);
|
||||
bool Do(void *ptr, int size);
|
||||
|
||||
bool DoArray(void *ptr, int size, int arrSize);
|
||||
|
||||
// Future
|
||||
// bool DoCompressed(void *ptr, int size)
|
||||
|
||||
// Store maps to file. Very useful.
|
||||
template<class T>
|
||||
void Do(std::map<u32, T> &x) {
|
||||
|
||||
bool Do(std::map<u32, T> &x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store vectors.
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x) {
|
||||
bool Do(std::vector<T> &x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Disable size checks to save size for variable size array storing
|
||||
template<clsas T>
|
||||
bool DoArray(T *x, int size, int arrSize) {
|
||||
return DoArray((void *)x, size, arrSize);
|
||||
}
|
||||
|
||||
// Handle everything else
|
||||
template<class T>
|
||||
void Do(T &x) {
|
||||
Do((void *)&x, sizeof(x));
|
||||
bool Do(T &x) {
|
||||
return Do((void *)&x, sizeof(x));
|
||||
}
|
||||
|
||||
int GetCurrentChunkSize();
|
||||
|
Loading…
Reference in New Issue
Block a user