summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/BreakPoints.cpp15
-rw-r--r--Source/Core/Common/Src/ChunkFile.h2
-rw-r--r--Source/Core/Common/Src/Common.h3
-rw-r--r--Source/Core/Common/Src/CommonPaths.h2
-rw-r--r--Source/Core/Common/Src/FileSearch.cpp35
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp14
-rw-r--r--Source/Core/Common/Src/FileUtil.h2
-rw-r--r--Source/Core/Common/Src/LinearDiskCache.h2
-rw-r--r--Source/Core/Common/Src/SDCardUtil.cpp98
-rw-r--r--Source/Core/Common/Src/StdMutex.h5
10 files changed, 101 insertions, 77 deletions
diff --git a/Source/Core/Common/Src/BreakPoints.cpp b/Source/Core/Common/Src/BreakPoints.cpp
index 1700276d85..62fadefd4f 100644
--- a/Source/Core/Common/Src/BreakPoints.cpp
+++ b/Source/Core/Common/Src/BreakPoints.cpp
@@ -19,7 +19,9 @@
#include "DebugInterface.h"
#include "BreakPoints.h"
#include "../../Core/Src/PowerPC/JitCommon/JitBase.h"
+
#include <sstream>
+#include <algorithm>
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
{
@@ -110,12 +112,17 @@ void BreakPoints::Remove(u32 em_address)
void BreakPoints::Clear()
{
- for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
+ if (jit)
{
- if (jit)
- jit->GetBlockCache()->InvalidateICache(i->iAddress, 4);
- m_BreakPoints.erase(i);
+ std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(),
+ [](const TBreakPoint& bp)
+ {
+ jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
+ }
+ );
}
+
+ m_BreakPoints.clear();
}
MemChecks::TMemChecksStr MemChecks::GetStrings() const
diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h
index be8b49a3a3..38e1b2176c 100644
--- a/Source/Core/Common/Src/ChunkFile.h
+++ b/Source/Core/Common/Src/ChunkFile.h
@@ -155,7 +155,7 @@ public:
Do(stringLen);
switch (mode) {
- case MODE_READ: x = (wchar_t*)*ptr; break;
+ case MODE_READ: x.assign((wchar_t*)*ptr, (stringLen / sizeof(wchar_t)) - 1); break;
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
case MODE_MEASURE: break;
case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break;
diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h
index 884a1e6c16..c3cab37dd8 100644
--- a/Source/Core/Common/Src/Common.h
+++ b/Source/Core/Common/Src/Common.h
@@ -81,8 +81,9 @@ private:
#define GC_ALIGNED16_DECL(x) __declspec(align(16)) x
#define GC_ALIGNED64_DECL(x) __declspec(align(64)) x
-// Since it is always around on windows
+// Since they are always around on windows
#define HAVE_WX 1
+ #define HAVE_OPENAL 1
#define HAVE_PORTAUDIO 1
diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h
index 430a0c0cd8..9e14d7cf7e 100644
--- a/Source/Core/Common/Src/CommonPaths.h
+++ b/Source/Core/Common/Src/CommonPaths.h
@@ -89,11 +89,11 @@
#define MAIL_LOGS_DIR LOGS_DIR DIR_SEP "Mail"
#define SHADERS_DIR "Shaders"
#define WII_SYSCONF_DIR "shared2" DIR_SEP "sys"
+#define THEMES_DIR "Themes"
// Filenames
// Files in the directory returned by GetUserPath(D_CONFIG_IDX)
#define DOLPHIN_CONFIG "Dolphin.ini"
-#define DSP_CONFIG "DSP.ini"
#define DEBUGGER_CONFIG "Debugger.ini"
#define LOGGER_CONFIG "Logger.ini"
diff --git a/Source/Core/Common/Src/FileSearch.cpp b/Source/Core/Common/Src/FileSearch.cpp
index c60ce9beda..595dfe7000 100644
--- a/Source/Core/Common/Src/FileSearch.cpp
+++ b/Source/Core/Common/Src/FileSearch.cpp
@@ -25,6 +25,7 @@
#endif
#include <string>
+#include <algorithm>
#include "FileSearch.h"
@@ -72,36 +73,36 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
#else
- size_t dot_pos = _searchString.rfind(".");
+ // TODO: super lame/broken
- if (dot_pos == std::string::npos)
- return;
+ auto end_match(_searchString);
+
+ // assuming we have a "*.blah"-like pattern
+ if (!end_match.empty() && end_match[0] == '*')
+ end_match.erase(0, 1);
+
+ // ugly
+ if (end_match == ".*")
+ end_match.clear();
- std::string ext = _searchString.substr(dot_pos);
DIR* dir = opendir(_strPath.c_str());
if (!dir)
return;
- dirent* dp;
-
- while (true)
+ while (auto const dp = readdir(dir))
{
- dp = readdir(dir);
-
- if (!dp)
- break;
-
- std::string s(dp->d_name);
+ std::string found(dp->d_name);
- if ( (!ext.compare(".*") && s.compare(".") && s.compare("..")) ||
- ((s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) ))
+ if ((found != ".") && (found != "..")
+ && (found.size() >= end_match.size())
+ && std::equal(end_match.rbegin(), end_match.rend(), found.rbegin()))
{
std::string full_name;
if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR)
- full_name = _strPath + s;
+ full_name = _strPath + found;
else
- full_name = _strPath + DIR_SEP + s;
+ full_name = _strPath + DIR_SEP + found;
m_FileNames.push_back(full_name);
}
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index 77290528a6..d74c99b7a2 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -512,12 +512,24 @@ bool DeleteDirRecursively(const std::string &directory)
if (IsDirectory(newPath))
{
if (!DeleteDirRecursively(newPath))
+ {
+ #ifndef _WIN32
+ closedir(dirp);
+ #endif
+
return false;
+ }
}
else
{
if (!File::Delete(newPath))
+ {
+ #ifndef _WIN32
+ closedir(dirp);
+ #endif
+
return false;
+ }
}
#ifdef _WIN32
@@ -678,9 +690,9 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
paths[D_DUMPDSP_IDX] = paths[D_USER_IDX] + DUMP_DSP_DIR DIR_SEP;
paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP;
paths[D_MAILLOGS_IDX] = paths[D_USER_IDX] + MAIL_LOGS_DIR DIR_SEP;
+ paths[D_THEMES_IDX] = paths[D_USER_IDX] + THEMES_DIR DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP;
paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
- paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG;
paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG;
paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG;
paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG;
diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h
index 9134bcf44e..451b1b6929 100644
--- a/Source/Core/Common/Src/FileUtil.h
+++ b/Source/Core/Common/Src/FileUtil.h
@@ -50,8 +50,8 @@ enum {
D_LOGS_IDX,
D_MAILLOGS_IDX,
D_WIISYSCONF_IDX,
+ D_THEMES_IDX,
F_DOLPHINCONFIG_IDX,
- F_DSPCONFIG_IDX,
F_DEBUGGERCONFIG_IDX,
F_LOGGERCONFIG_IDX,
F_MAINLOG_IDX,
diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h
index 4c746e9b75..9755c996bd 100644
--- a/Source/Core/Common/Src/LinearDiskCache.h
+++ b/Source/Core/Common/Src/LinearDiskCache.h
@@ -24,7 +24,7 @@
// Increment this every time you change shader generation code.
enum
{
- LINEAR_DISKCACHE_VER = 6975
+ LINEAR_DISKCACHE_VER = 6979
};
// On disk format:
diff --git a/Source/Core/Common/Src/SDCardUtil.cpp b/Source/Core/Common/Src/SDCardUtil.cpp
index 4002a51b99..0f2ad08607 100644
--- a/Source/Core/Common/Src/SDCardUtil.cpp
+++ b/Source/Core/Common/Src/SDCardUtil.cpp
@@ -40,7 +40,7 @@
#include <unistd.h> // for unlink()
#endif
-/* believe me, you *don't* want to change these constants !! */
+/* Believe me, you *don't* want to change these constants !! */
#define BYTES_PER_SECTOR 512
#define RESERVED_SECTORS 32
#define BACKUP_BOOT_SECTOR 6
@@ -52,15 +52,15 @@
#define POKES(p,v) ( BYTE_(p,0) = (u8)(v), BYTE_(p,1) = (u8)((v) >> 8) )
#define POKEW(p,v) ( BYTE_(p,0) = (u8)(v), BYTE_(p,1) = (u8)((v) >> 8), BYTE_(p,2) = (u8)((v) >> 16), BYTE_(p,3) = (u8)((v) >> 24) )
-static u8 s_boot_sector [ BYTES_PER_SECTOR ]; /* boot sector */
+static u8 s_boot_sector [ BYTES_PER_SECTOR ]; /* Boot sector */
static u8 s_fsinfo_sector [ BYTES_PER_SECTOR ]; /* FS Info sector */
-static u8 s_fat_head [ BYTES_PER_SECTOR ]; /* first FAT sector */
+static u8 s_fat_head [ BYTES_PER_SECTOR ]; /* First FAT sector */
-/* this is the date and time when creating the disk */
-static int get_serial_id()
+/* This is the date and time when creating the disk */
+static unsigned int get_serial_id()
{
u16 lo, hi;
- time_t now = time(NULL);
+ time_t now = time(nullptr);
struct tm tm = gmtime( &now )[0];
lo = (u16)(tm.tm_mday + ((tm.tm_mon+1) << 8) + (tm.tm_sec << 8));
@@ -69,7 +69,7 @@ static int get_serial_id()
return lo + (hi << 16);
}
-static int get_sectors_per_cluster(u64 disk_size)
+static unsigned int get_sectors_per_cluster(u64 disk_size)
{
u64 disk_MB = disk_size/(1024*1024);
@@ -88,60 +88,60 @@ static int get_sectors_per_cluster(u64 disk_size)
return 32;
}
-static int get_sectors_per_fat(u64 disk_size, int sectors_per_cluster)
+static unsigned int get_sectors_per_fat(u64 disk_size, u32 sectors_per_cluster)
{
u64 divider;
- /* weird computation from MS - see fatgen103.doc for details */
- disk_size -= RESERVED_SECTORS * BYTES_PER_SECTOR; /* don't count 32 reserved sectors */
- disk_size /= BYTES_PER_SECTOR; /* disk size in sectors */
+ /* Weird computation from MS - see fatgen103.doc for details */
+ disk_size -= RESERVED_SECTORS * BYTES_PER_SECTOR; /* Don't count 32 reserved sectors */
+ disk_size /= BYTES_PER_SECTOR; /* Disk size in sectors */
divider = ((256 * sectors_per_cluster) + NUM_FATS) / 2;
- return (int)( (disk_size + (divider-1)) / divider );
+ return (u32)( (disk_size + (divider-1)) / divider );
}
static void boot_sector_init(u8* boot, u8* info, u64 disk_size, const char* label)
{
- int sectors_per_cluster = get_sectors_per_cluster(disk_size);
- int sectors_per_fat = get_sectors_per_fat(disk_size, sectors_per_cluster);
- int sectors_per_disk = (int)(disk_size / BYTES_PER_SECTOR);
- int serial_id = get_serial_id();
- int free_count;
+ u32 sectors_per_cluster = get_sectors_per_cluster(disk_size);
+ u32 sectors_per_fat = get_sectors_per_fat(disk_size, sectors_per_cluster);
+ u32 sectors_per_disk = (u32)(disk_size / BYTES_PER_SECTOR);
+ u32 serial_id = get_serial_id();
+ u32 free_count;
- if (label == NULL)
+ if (label == nullptr)
label = "DOLPHINSD";
POKEB(boot, 0xeb);
POKEB(boot+1, 0x5a);
POKEB(boot+2, 0x90);
strcpy( (char*)boot + 3, "MSWIN4.1" );
- POKES( boot + 0x0b, BYTES_PER_SECTOR ); /* sector size */
- POKEB( boot + 0xd, sectors_per_cluster ); /* sectors per cluster */
- POKES( boot + 0xe, RESERVED_SECTORS ); /* reserved sectors before first FAT */
- POKEB( boot + 0x10, NUM_FATS ); /* number of FATs */
- POKES( boot + 0x11, 0 ); /* max root directory entries for FAT12/FAT16, 0 for FAT32 */
- POKES( boot + 0x13, 0 ); /* total sectors, 0 to use 32-bit value at offset 0x20 */
- POKEB( boot + 0x15, 0xF8 ); /* media descriptor, 0xF8 == hard disk */
+ POKES( boot + 0x0b, BYTES_PER_SECTOR ); /* Sector size */
+ POKEB( boot + 0xd, sectors_per_cluster ); /* Sectors per cluster */
+ POKES( boot + 0xe, RESERVED_SECTORS ); /* Reserved sectors before first FAT */
+ POKEB( boot + 0x10, NUM_FATS ); /* Number of FATs */
+ POKES( boot + 0x11, 0 ); /* Max root directory entries for FAT12/FAT16, 0 for FAT32 */
+ POKES( boot + 0x13, 0 ); /* Total sectors, 0 to use 32-bit value at offset 0x20 */
+ POKEB( boot + 0x15, 0xF8 ); /* Media descriptor, 0xF8 == hard disk */
POKES( boot + 0x16, 0 ); /* Sectors per FAT for FAT12/16, 0 for FAT32 */
POKES( boot + 0x18, 9 ); /* Sectors per track (whatever) */
POKES( boot + 0x1a, 2 ); /* Number of heads (whatever) */
POKEW( boot + 0x1c, 0 ); /* Hidden sectors */
POKEW( boot + 0x20, sectors_per_disk ); /* Total sectors */
- /* extension */
+ /* Extension */
POKEW( boot + 0x24, sectors_per_fat ); /* Sectors per FAT */
POKES( boot + 0x28, 0 ); /* FAT flags */
- POKES( boot + 0x2a, 0 ); /* version */
- POKEW( boot + 0x2c, 2 ); /* cluster number of root directory start */
- POKES( boot + 0x30, 1 ); /* sector number of FS information sector */
- POKES( boot + 0x32, BACKUP_BOOT_SECTOR ); /* sector number of a copy of this boot sector */
- POKEB( boot + 0x40, 0x80 ); /* physical drive number */
- POKEB( boot + 0x42, 0x29 ); /* extended boot signature ?? */
- POKEW( boot + 0x43, serial_id ); /* serial ID */
+ POKES( boot + 0x2a, 0 ); /* Version */
+ POKEW( boot + 0x2c, 2 ); /* Cluster number of root directory start */
+ POKES( boot + 0x30, 1 ); /* Sector number of FS information sector */
+ POKES( boot + 0x32, BACKUP_BOOT_SECTOR ); /* Sector number of a copy of this boot sector */
+ POKEB( boot + 0x40, 0x80 ); /* Physical drive number */
+ POKEB( boot + 0x42, 0x29 ); /* Extended boot signature ?? */
+ POKEW( boot + 0x43, serial_id ); /* Serial ID */
strncpy( (char*)boot + 0x47, label, 11 ); /* Volume Label */
memcpy( boot + 0x52, "FAT32 ", 8 ); /* FAT system type, padded with 0x20 */
- POKEB( boot + BYTES_PER_SECTOR-2, 0x55 ); /* boot sector signature */
+ POKEB( boot + BYTES_PER_SECTOR-2, 0x55 ); /* Boot sector signature */
POKEB( boot + BYTES_PER_SECTOR-1, 0xAA );
/* FSInfo sector */
@@ -149,25 +149,25 @@ static void boot_sector_init(u8* boot, u8* info, u64 disk_size, const char* labe
POKEW( info + 0, 0x41615252 );
POKEW( info + 484, 0x61417272 );
- POKEW( info + 488, free_count ); /* number of free clusters */
- POKEW( info + 492, 3 ); /* next free clusters, 0-1 reserved, 2 is used for the root dir */
+ POKEW( info + 488, free_count ); /* Number of free clusters */
+ POKEW( info + 492, 3 ); /* Next free clusters, 0-1 reserved, 2 is used for the root dir */
POKEW( info + 508, 0xAA550000 );
}
static void fat_init(u8* fat)
{
- POKEW( fat, 0x0ffffff8 ); /* reserve cluster 1, media id in low byte */
- POKEW( fat + 4, 0x0fffffff ); /* reserve cluster 2 */
- POKEW( fat + 8, 0x0fffffff ); /* end of clust chain for root dir */
+ POKEW( fat, 0x0ffffff8 ); /* Reserve cluster 1, media id in low byte */
+ POKEW( fat + 4, 0x0fffffff ); /* Reserve cluster 2 */
+ POKEW( fat + 8, 0x0fffffff ); /* End of cluster chain for root dir */
}
-static int write_sector(FILE* file, u8* sector)
+static unsigned int write_sector(FILE* file, u8* sector)
{
return fwrite(sector, 1, 512, file) != 512;
}
-static int write_empty(FILE* file, u64 count)
+static unsigned int write_empty(FILE* file, u64 count)
{
static u8 empty[64*1024];
@@ -188,8 +188,8 @@ static int write_empty(FILE* file, u64 count)
bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
{
- int sectors_per_fat;
- int sectors_per_disk;
+ u32 sectors_per_fat;
+ u32 sectors_per_disk;
FILE* f;
// Convert MB to bytes
@@ -200,21 +200,21 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
return false;
}
- // pretty unlikely to overflow.
- sectors_per_disk = (int)(disk_size / 512);
+ // Pretty unlikely to overflow.
+ sectors_per_disk = (u32)(disk_size / 512);
sectors_per_fat = get_sectors_per_fat(disk_size, get_sectors_per_cluster(disk_size));
- boot_sector_init(s_boot_sector, s_fsinfo_sector, disk_size, NULL );
+ boot_sector_init(s_boot_sector, s_fsinfo_sector, disk_size, nullptr);
fat_init(s_fat_head);
f = fopen(filename, "wb");
if (!f)
{
- ERROR_LOG(COMMON, "could not create file '%s', aborting...\n", filename);
+ ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename);
return false;
}
- /* here's the layout:
+ /* Here's the layout:
*
* boot_sector
* fsinfo_sector
@@ -251,7 +251,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
return true;
FailWrite:
- ERROR_LOG(COMMON, "could not write to '%s', aborting...\n", filename);
+ ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename);
if (unlink(filename) < 0)
ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename, GetLastErrorMsg());
fclose(f);
diff --git a/Source/Core/Common/Src/StdMutex.h b/Source/Core/Common/Src/StdMutex.h
index 150d18f53e..8949e905ac 100644
--- a/Source/Core/Common/Src/StdMutex.h
+++ b/Source/Core/Common/Src/StdMutex.h
@@ -318,9 +318,12 @@ public:
mutex_type* release()
{
- return mutex();
+ auto const ret = mutex();
+
pm = NULL;
owns = false;
+
+ return ret;
}
bool owns_lock() const