summaryrefslogtreecommitdiff
path: root/Source/Core/Common
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
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')
-rw-r--r--Source/Core/Common/Common.vcproj74
-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
8 files changed, 137 insertions, 37 deletions
diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj
index e8e4545d7f..53f3639aa4 100644
--- a/Source/Core/Common/Common.vcproj
+++ b/Source/Core/Common/Common.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="8.00"
Name="Common"
ProjectGUID="{C573CAF7-EE6A-458E-8049-16C0BF34C2E9}"
RootNamespace="Common"
@@ -89,7 +89,7 @@
/>
</Configuration>
<Configuration
- Name="Release|Win32"
+ Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
@@ -111,19 +111,19 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="2"
+ Optimization="0"
AdditionalIncludeDirectories="../../PluginSpecs"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0"
+ StringPooling="true"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
BufferSecurityCheck="false"
- EnableEnhancedInstructionSet="2"
FloatingPointModel="0"
- RuntimeTypeInfo="false"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
AssemblerListingLocation="$(IntDir)\"
@@ -163,7 +163,7 @@
/>
</Configuration>
<Configuration
- Name="DebugFast|Win32"
+ Name="Release|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
@@ -188,13 +188,16 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="3"
- FavorSizeOrSpeed="1"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="2"
AdditionalIncludeDirectories="../../PluginSpecs"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;LOGGING"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
+ FloatingPointModel="0"
+ RuntimeTypeInfo="false"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
AssemblerListingLocation="$(IntDir)\"
@@ -234,7 +237,7 @@
/>
</Configuration>
<Configuration
- Name="Debug|x64"
+ Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
@@ -260,14 +263,15 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../../PluginSpecs"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0"
StringPooling="true"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ RuntimeLibrary="0"
BufferSecurityCheck="false"
+ EnableEnhancedInstructionSet="0"
FloatingPointModel="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
@@ -288,7 +292,7 @@
/>
<Tool
Name="VCLibrarianTool"
- AdditionalDependencies="wsock32.lib"
+ AdditionalDependencies="wsock32.lib winmm.lib"
OutputFile="$(OutDir)/Common.lib"
/>
<Tool
@@ -308,7 +312,7 @@
/>
</Configuration>
<Configuration
- Name="Release|x64"
+ Name="DebugFast|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
@@ -330,20 +334,16 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
+ Optimization="3"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../../PluginSpecs"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0"
- StringPooling="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;LOGGING"
RuntimeLibrary="0"
BufferSecurityCheck="false"
- EnableEnhancedInstructionSet="0"
- FloatingPointModel="0"
+ EnableEnhancedInstructionSet="2"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
AssemblerListingLocation="$(IntDir)\"
@@ -363,7 +363,7 @@
/>
<Tool
Name="VCLibrarianTool"
- AdditionalDependencies="wsock32.lib winmm.lib"
+ AdditionalDependencies="wsock32.lib"
OutputFile="$(OutDir)/Common.lib"
/>
<Tool
@@ -490,6 +490,14 @@
>
</File>
<File
+ RelativePath=".\Src\DriveUtil.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\DriveUtil.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\DynamicLibrary.cpp"
>
</File>
@@ -597,7 +605,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -605,7 +613,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="DebugFast|Win32"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -613,7 +621,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -621,7 +629,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|x64"
+ Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
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