Large blob code cleanup. Compressed ISO ("gcz") support reactivated. Beginnings of raw drive reading code. Deprecate file mapping in an ugly way.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@566 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-09-17 23:25:35 +00:00
parent 2cd7acfaee
commit cb90e61368
31 changed files with 1209 additions and 844 deletions

View File

@ -18,7 +18,14 @@
#ifndef _COMMON_H
#define _COMMON_H
#define _CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC_NEW
#ifdef _WIN32
#ifdef _DEBUG
#include <crtdbg.h>
#endif
#include "../../../PluginSpecs/CommonTypes.h"
#else
#include "CommonTypes.h"

View File

@ -0,0 +1,57 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#ifdef _WIN32
#include <windows.h>
#include <winioctl.h>
#endif
void GetAllRemovableDrives(std::vector<std::string> *drives) {
drives->clear();
#ifdef _WIN32
HANDLE hDisk;
DISK_GEOMETRY diskGeometry;
for (int i = 'A'; i < 'Z'; i++)
{
char path[MAX_PATH];
sprintf(path, "\\\\.\\%c:", i);
hDisk = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hDisk != INVALID_HANDLE_VALUE)
{
DWORD dwBytes;
DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof(DISK_GEOMETRY), &dwBytes, NULL);
// Only proceed if disk is a removable media
if (diskGeometry.MediaType == RemovableMedia)
{
if (diskGeometry.BytesPerSector == 2048) {
// Probably CD/DVD drive.
// "Remove" the "\\.\" part of the path and return it.
drives->push_back(path + 4);
}
}
}
CloseHandle(hDisk);
}
#else
// TODO
// stat("/media/cdrom") or whatever etc etc
#endif
}

View File

@ -0,0 +1,28 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _DRIVEUTIL_H
#define _DRIVEUTIL_H
#include <string>
#include <vector>
// Tools to enumerate drives (HDD, DVD, CD) in a platform-independent manner.
void GetAllRemovableDrives(std::vector<std::string> *drives);
#endif

View File

@ -28,7 +28,7 @@ public:
static void Explore(const std::string &path);
static bool IsDirectory(const std::string &filename);
static bool CreateDir(const std::string &filename);
static std::string GetUserDirectory();
static std::string GetUserDirectory();
};
#endif

View File

@ -19,7 +19,7 @@
#include "Common.h"
u32 HashFletcher(const u8* data_u8, size_t length); // FAST
u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0.
u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower
u32 HashFNV(const u8* ptr, int length); // Another fast and decent hash
u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS

View File

@ -226,7 +226,7 @@ void CMappedFile::Unlock(u8* ptr)
}
IMappedFile* IMappedFile::CreateMappedFile(void)
IMappedFile* IMappedFile::CreateMappedFileDEPRECATED(void)
{
return(new CMappedFile);
}

View File

@ -43,7 +43,7 @@ class IMappedFile
virtual u8* Lock(u64 _offset, u64 _size) = 0;
virtual void Unlock(u8* ptr) = 0;
static IMappedFile* CreateMappedFile();
static IMappedFile* CreateMappedFileDEPRECATED();
};
} // end of namespace DiscIO