Fix "Common" to build with "Unicode" project setting.

This commit is contained in:
Jordan Woyak
2013-02-27 18:51:02 -06:00
parent ea75577278
commit 69f7671ee8
10 changed files with 63 additions and 59 deletions

View File

@ -6,6 +6,7 @@
#include <memory> // for std::unique_ptr
#ifdef _WIN32
#include <windows.h>
#include "StringUtil.h"
#elif __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOBSD.h>
@ -25,7 +26,7 @@
#ifdef _WIN32
// takes a root drive path, returns true if it is a cdrom drive
bool is_cdrom(const char drive[])
bool is_cdrom(const TCHAR* drive)
{
return (DRIVE_CDROM == GetDriveType(drive));
}
@ -36,15 +37,15 @@ std::vector<std::string> cdio_get_devices()
std::vector<std::string> drives;
const DWORD buffsize = GetLogicalDriveStrings(0, NULL);
std::unique_ptr<char[]> buff(new char[buffsize]);
if (GetLogicalDriveStrings(buffsize, buff.get()) == buffsize - 1)
std::vector<TCHAR> buff(buffsize);
if (GetLogicalDriveStrings(buffsize, buff.data()) == buffsize - 1)
{
const char* drive = buff.get();
auto drive = buff.data();
while (*drive)
{
if (is_cdrom(drive))
{
std::string str(drive);
std::string str(TStrToUTF8(drive));
str.pop_back(); // we don't want the final backslash
drives.push_back(std::move(str));
}