summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2008-09-17 23:25:35 +0000
committerhrydgard <hrydgard@gmail.com>2008-09-17 23:25:35 +0000
commitcb90e613680195e853fd05f5ef8bbd82fe577682 (patch)
tree48673444768616300a1c3258f847cb0bc36539a1 /Source/Core/Common/Src
parent2cd7acfaee5756f119afd18e55f3437b9df3ab8b (diff)
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
Diffstat (limited to 'Source/Core/Common/Src')
-rw-r--r--Source/Core/Common/Src/Common.h7
-rw-r--r--Source/Core/Common/Src/DriveUtil.cpp57
-rw-r--r--Source/Core/Common/Src/DriveUtil.h28
-rw-r--r--Source/Core/Common/Src/FileUtil.h2
-rw-r--r--Source/Core/Common/Src/Hash.h2
-rw-r--r--Source/Core/Common/Src/MappedFile.cpp2
-rw-r--r--Source/Core/Common/Src/MappedFile.h2
7 files changed, 96 insertions, 4 deletions
diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h
index 6160e5e449..242bd25694 100644
--- a/Source/Core/Common/Src/Common.h
+++ b/Source/Core/Common/Src/Common.h
@@ -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"
diff --git a/Source/Core/Common/Src/DriveUtil.cpp b/Source/Core/Common/Src/DriveUtil.cpp
new file mode 100644
index 0000000000..2190eb326d
--- /dev/null
+++ b/Source/Core/Common/Src/DriveUtil.cpp
@@ -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
+}
+
diff --git a/Source/Core/Common/Src/DriveUtil.h b/Source/Core/Common/Src/DriveUtil.h
new file mode 100644
index 0000000000..987d0a937f
--- /dev/null
+++ b/Source/Core/Common/Src/DriveUtil.h
@@ -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
diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h
index e65a43be91..f64d31f6c2 100644
--- a/Source/Core/Common/Src/FileUtil.h
+++ b/Source/Core/Common/Src/FileUtil.h
@@ -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
diff --git a/Source/Core/Common/Src/Hash.h b/Source/Core/Common/Src/Hash.h
index 066915cb91..f2e1df42da 100644
--- a/Source/Core/Common/Src/Hash.h
+++ b/Source/Core/Common/Src/Hash.h
@@ -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
diff --git a/Source/Core/Common/Src/MappedFile.cpp b/Source/Core/Common/Src/MappedFile.cpp
index e22e121722..29b86285c0 100644
--- a/Source/Core/Common/Src/MappedFile.cpp
+++ b/Source/Core/Common/Src/MappedFile.cpp
@@ -226,7 +226,7 @@ void CMappedFile::Unlock(u8* ptr)
}
-IMappedFile* IMappedFile::CreateMappedFile(void)
+IMappedFile* IMappedFile::CreateMappedFileDEPRECATED(void)
{
return(new CMappedFile);
}
diff --git a/Source/Core/Common/Src/MappedFile.h b/Source/Core/Common/Src/MappedFile.h
index bd359ef7dd..1536672f81 100644
--- a/Source/Core/Common/Src/MappedFile.h
+++ b/Source/Core/Common/Src/MappedFile.h
@@ -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