mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 22:09:19 -07:00
d616f132d7
Debugger panel is displayed only if Dolphin is started with /d option. Dump features are not implemented. Pause/Resume buttons works, only if the plugin is built in DEBUG or DEBUGFAST configuration, not in RELEASE. These features are really only for devs, not for regular gamers. You will be able to pause frame by frame, or by n frames, or by n primitive flushes. Other pausing options are not implemented yet. When other pausing and dumping features are implemented, debugging will be much easier. I have changed the DX9 project setting to use unicode character set in order to use wxWidge tools. If this causes Dolphin building problems for you, check your project setting.txt git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4154 8ced0084-cf51-0410-be5f-012b33b47a6e
148 lines
2.3 KiB
C++
148 lines
2.3 KiB
C++
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "File.h"
|
|
|
|
|
|
namespace W32Util
|
|
{
|
|
|
|
File::File()
|
|
{
|
|
fileHandle = INVALID_HANDLE_VALUE;
|
|
isOpen=false;
|
|
}
|
|
|
|
File::~File()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
bool File::Open(const TCHAR *filename, eFileMode _mode)
|
|
{
|
|
mode = _mode;
|
|
//it's time to open the file
|
|
fileHandle = CreateFile(filename,
|
|
mode==FILE_READ ? GENERIC_READ : GENERIC_WRITE, //open mode
|
|
mode == FILE_READ ? FILE_SHARE_READ : NULL, //sharemode
|
|
NULL, //security
|
|
mode==FILE_READ ? OPEN_EXISTING : CREATE_ALWAYS, //create mode
|
|
FILE_ATTRIBUTE_NORMAL, //atrributes
|
|
NULL); //template
|
|
|
|
if (fileHandle == INVALID_HANDLE_VALUE)
|
|
isOpen=false;
|
|
else
|
|
isOpen=true;
|
|
|
|
return isOpen;
|
|
}
|
|
|
|
|
|
void File::Close()
|
|
{
|
|
if (isOpen)
|
|
{
|
|
//close the file and reset variables
|
|
CloseHandle(fileHandle);
|
|
fileHandle=INVALID_HANDLE_VALUE;
|
|
isOpen=false;
|
|
}
|
|
}
|
|
|
|
int File::GetSize()
|
|
{
|
|
if (!isOpen) //of course
|
|
return 0;
|
|
else
|
|
return GetFileSize(fileHandle,0);
|
|
}
|
|
|
|
int File::Write(void *data, int size) //let's do some writing
|
|
{
|
|
if (isOpen)
|
|
{
|
|
DWORD written;
|
|
WriteFile(fileHandle, data, size, &written,0);
|
|
return written; //we return the number of bytes that actually got written
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int File::Read(void *data, int size)
|
|
{
|
|
if (isOpen)
|
|
{
|
|
DWORD wasRead;
|
|
ReadFile(fileHandle, data, size, &wasRead,0);
|
|
return wasRead; //we return the number of bytes that actually was read
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int File::WR(void *data, int size)
|
|
{
|
|
if (mode==FILE_READ)
|
|
return Read(data,size);
|
|
else
|
|
return Write(data,size);
|
|
}
|
|
bool File::MagicCookie(int cookie)
|
|
{
|
|
if (mode==FILE_READ)
|
|
{
|
|
if (ReadInt()!=cookie)
|
|
{
|
|
char mojs[5],temp[256];
|
|
mojs[4]=0;
|
|
*(int*)mojs=cookie;
|
|
sprintf(temp,"W32Util::File: Magic Cookie %s is bad!",mojs);
|
|
MessageBoxA(0,temp,"Error reading file",MB_ICONERROR);
|
|
return false;
|
|
}
|
|
else
|
|
return true;
|
|
}
|
|
else if (mode==FILE_WRITE)
|
|
{
|
|
WriteInt(cookie);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int File::ReadInt()
|
|
{
|
|
int temp;
|
|
if (Read(&temp, sizeof(int)))
|
|
return temp;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
void File::WriteInt(int i)
|
|
{
|
|
Write(&i,sizeof(int));
|
|
}
|
|
|
|
char File::ReadChar()
|
|
{
|
|
char temp;
|
|
if (Read(&temp, sizeof(char)))
|
|
return temp;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
void File::WriteChar(char i)
|
|
{
|
|
Write(&i,sizeof(char));
|
|
}
|
|
} |