mirror of https://github.com/PCSX2/pcsx2.git
Darwin/OSX flat file reader stub.
This commit is contained in:
parent
be720b96c1
commit
c15958f3c2
|
@ -18,8 +18,10 @@
|
|||
#ifdef WIN32
|
||||
# include <Windows.h>
|
||||
# undef Yield
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
# include <libaio.h>
|
||||
#elif defined(__APPLE__)
|
||||
# include <aio.h>
|
||||
#endif
|
||||
|
||||
class AsyncFileReader
|
||||
|
@ -70,9 +72,12 @@ class FlatFileReader : public AsyncFileReader
|
|||
HANDLE hEvent;
|
||||
|
||||
bool asyncInProgress;
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
int m_fd; // FIXME don't know if overlap as an equivalent on linux
|
||||
io_context_t m_aio_context;
|
||||
#elif defined(__POSIX__)
|
||||
int m_fd; // TODO OSX don't know if overlap as an equivalent on OSX
|
||||
struct aiocb m_aio_context;
|
||||
#endif
|
||||
|
||||
bool shareWrite;
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 PCSX2 Dev Team
|
||||
*
|
||||
* 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-
|
||||
* 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;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* 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.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "AsyncFileReader.h"
|
||||
|
||||
#warning This reader is not yet implemented. Crash boom bang if used
|
||||
|
||||
//FlatFileReader::FlatFileReader(void)
|
||||
FlatFileReader::FlatFileReader(bool shareWrite) : shareWrite(shareWrite)
|
||||
{
|
||||
printf("FLATC\n");
|
||||
m_blocksize = 2048;
|
||||
m_fd = 0;
|
||||
//m_aio_context = 0;
|
||||
}
|
||||
|
||||
FlatFileReader::~FlatFileReader(void)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
bool FlatFileReader::Open(const wxString& fileName)
|
||||
{
|
||||
printf("OB\n");
|
||||
m_filename = fileName;
|
||||
|
||||
int err = 0; //io_setup(64, &m_aio_context);
|
||||
if (err) return false;
|
||||
|
||||
m_fd = wxOpen(fileName, O_RDONLY, 0);
|
||||
|
||||
return (m_fd != 0);
|
||||
}
|
||||
|
||||
int FlatFileReader::ReadSync(void* pBuffer, uint sector, uint count)
|
||||
{
|
||||
printf("RAD\n");
|
||||
BeginRead(pBuffer, sector, count);
|
||||
return FinishRead();
|
||||
}
|
||||
|
||||
void FlatFileReader::BeginRead(void* pBuffer, uint sector, uint count)
|
||||
{
|
||||
printf("RWEADB\n");
|
||||
u64 offset;
|
||||
offset = sector * (u64)m_blocksize + m_dataoffset;
|
||||
|
||||
u32 bytesToRead = count * m_blocksize;
|
||||
|
||||
struct aiocb iocb;
|
||||
struct aiocb* iocbs = &iocb;
|
||||
|
||||
//io_prep_pread(&iocb, m_fd, pBuffer, bytesToRead, offset);
|
||||
//io_submit(m_aio_context, 1, &iocbs);
|
||||
}
|
||||
|
||||
int FlatFileReader::FinishRead(void)
|
||||
{
|
||||
printf("FINISH\n");
|
||||
u32 bytes;
|
||||
|
||||
int min_nr = 1;
|
||||
int max_nr = 1;
|
||||
/* struct io_event* events = new io_event[max_nr];
|
||||
|
||||
int event = io_getevents(m_aio_context, min_nr, max_nr, events, NULL);
|
||||
if (event < 1) {
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FlatFileReader::CancelRead(void)
|
||||
{
|
||||
printf("CANCEL\n");
|
||||
// Will be done when m_aio_context context is destroyed
|
||||
// Note: io_cancel exists but need the iocb structure as parameter
|
||||
// int io_cancel(aio_context_t ctx_id, struct iocb *iocb,
|
||||
// struct io_event *result);
|
||||
}
|
||||
|
||||
void FlatFileReader::Close(void)
|
||||
{
|
||||
printf("CLOSE\n");
|
||||
if (m_fd) close(m_fd);
|
||||
|
||||
//io_destroy(m_aio_context);
|
||||
aio_cancel(m_fd, &m_aio_context);
|
||||
|
||||
m_fd = 0;
|
||||
//m_aio_context = 0;
|
||||
}
|
||||
|
||||
uint FlatFileReader::GetBlockCount(void) const
|
||||
{
|
||||
printf("BLOCKS\n");
|
||||
return (int)(Path::GetFileSize(m_filename) / m_blocksize);
|
||||
}
|
Loading…
Reference in New Issue