Allow to share writing to the ISO through an ini option

This commit is contained in:
Kingcom 2014-08-15 22:48:12 +02:00
parent 7e5b6dee9c
commit f5fe75a73b
6 changed files with 31 additions and 20 deletions

View File

@ -75,8 +75,10 @@ class FlatFileReader : public AsyncFileReader
io_context_t m_aio_context; io_context_t m_aio_context;
#endif #endif
bool shareWrite;
public: public:
FlatFileReader(void); FlatFileReader(bool shareWrite = false);
virtual ~FlatFileReader(void); virtual ~FlatFileReader(void);
virtual bool Open(const wxString& fileName); virtual bool Open(const wxString& fileName);

View File

@ -201,7 +201,10 @@ bool InputIsoFile::Open( const wxString& srcfile, bool testOnly )
Close(); Close();
m_filename = srcfile; m_filename = srcfile;
m_reader = new FlatFileReader(); // Allow write sharing of the iso based on the ini settings.
// Mostly useful for romhacking, where the disc is frequently
// changed and the emulator would block modifications
m_reader = new FlatFileReader(EmuConfig.CdvdShareWrite);
m_reader->Open(m_filename); m_reader->Open(m_filename);
bool isBlockdump, isCompressed = false; bool isBlockdump, isCompressed = false;

View File

@ -433,6 +433,7 @@ struct Pcsx2Config
bool bool
CdvdVerboseReads :1, // enables cdvd read activity verbosely dumped to the console CdvdVerboseReads :1, // enables cdvd read activity verbosely dumped to the console
CdvdDumpBlocks :1, // enables cdvd block dumping CdvdDumpBlocks :1, // enables cdvd block dumping
CdvdShareWrite :1, // allows the iso to be modified while it's loaded
EnablePatches :1, // enables patch detection and application EnablePatches :1, // enables patch detection and application
EnableCheats :1, // enables cheat detection and application EnableCheats :1, // enables cheat detection and application
EnableWideScreenPatches :1, EnableWideScreenPatches :1,

View File

@ -16,7 +16,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "AsyncFileReader.h" #include "AsyncFileReader.h"
FlatFileReader::FlatFileReader(void) FlatFileReader::FlatFileReader(bool shareWrite) : shareWrite(shareWrite)
{ {
m_blocksize = 2048; m_blocksize = 2048;
m_fd = 0; m_fd = 0;

View File

@ -410,6 +410,7 @@ void Pcsx2Config::LoadSave( IniInterface& ini )
IniBitBool( CdvdVerboseReads ); IniBitBool( CdvdVerboseReads );
IniBitBool( CdvdDumpBlocks ); IniBitBool( CdvdDumpBlocks );
IniBitBool( CdvdShareWrite );
IniBitBool( EnablePatches ); IniBitBool( EnablePatches );
IniBitBool( EnableCheats ); IniBitBool( EnableCheats );
IniBitBool( EnableWideScreenPatches ); IniBitBool( EnableWideScreenPatches );

View File

@ -1,22 +1,22 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2014 PCSX2 Dev Team * Copyright (C) 2002-2014 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version. * ation, either version 3 of the License, or (at your option) any later version.
* *
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details. * PURPOSE. See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along with PCSX2. * You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "AsyncFileReader.h" #include "AsyncFileReader.h"
FlatFileReader::FlatFileReader(void) FlatFileReader::FlatFileReader(bool shareWrite) : shareWrite(shareWrite)
{ {
m_blocksize = 2048; m_blocksize = 2048;
hOverlappedFile = INVALID_HANDLE_VALUE; hOverlappedFile = INVALID_HANDLE_VALUE;
@ -35,10 +35,14 @@ bool FlatFileReader::Open(const wxString& fileName)
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
DWORD shareMode = FILE_SHARE_READ;
if (shareWrite)
shareMode |= FILE_SHARE_WRITE;
hOverlappedFile = CreateFile( hOverlappedFile = CreateFile(
fileName, fileName,
GENERIC_READ, GENERIC_READ,
FILE_SHARE_READ, shareMode,
NULL, NULL,
OPEN_EXISTING, OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED, FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED,