mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Various small cleanups. Slightly less broken on Linux.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@635 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e8a3840461
commit
5254528eb9
@ -16,7 +16,7 @@
|
|||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
@ -36,9 +36,11 @@ namespace DiscIO
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii) :
|
CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii)
|
||||||
m_totalNameSize(0),
|
: m_totalNameSize(0)
|
||||||
m_FSTData(NULL), m_dataStartAddress(-1), m_fstSize(0)
|
, m_dataStartAddress(-1)
|
||||||
|
, m_fstSize(0)
|
||||||
|
, m_FSTData(NULL)
|
||||||
{
|
{
|
||||||
m_rootDirectory = ExtractDirectoryName(_rDirectory);
|
m_rootDirectory = ExtractDirectoryName(_rDirectory);
|
||||||
|
|
||||||
@ -69,9 +71,9 @@ CVolumeDirectory::~CVolumeDirectory()
|
|||||||
m_diskHeader = NULL;
|
m_diskHeader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
std::string directoryName = ExtractDirectoryName(_rDirectory);
|
std::string directoryName = ExtractDirectoryName(_rDirectory);
|
||||||
|
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
@ -81,13 +83,11 @@ bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
|
||||||
{
|
|
||||||
// TODO - Insert linux stuff here
|
// TODO - Insert linux stuff here
|
||||||
}
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ IVolume::ECountry CVolumeDirectory::GetCountry() const
|
|||||||
{
|
{
|
||||||
case 'S':
|
case 'S':
|
||||||
country = COUNTRY_EUROPE;
|
country = COUNTRY_EUROPE;
|
||||||
break; // PAL // <- that is shitty :) zelda demo disc
|
break; // PAL <- that is shitty :) zelda demo disc
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
country = COUNTRY_EUROPE;
|
country = COUNTRY_EUROPE;
|
||||||
@ -247,23 +247,33 @@ u64 CVolumeDirectory::GetSize() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char DIR_SEPARATOR =
|
||||||
|
#ifdef _WIN32
|
||||||
|
'\\';
|
||||||
|
#else
|
||||||
|
'/';
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string CVolumeDirectory::ExtractDirectoryName(const std::string& _rDirectory)
|
std::string CVolumeDirectory::ExtractDirectoryName(const std::string& _rDirectory)
|
||||||
{
|
{
|
||||||
std::string directoryName = _rDirectory;
|
std::string directoryName = _rDirectory;
|
||||||
|
|
||||||
size_t lastSlash = directoryName.find_last_of('\\');
|
size_t lastSep = directoryName.find_last_of(DIR_SEPARATOR);
|
||||||
|
|
||||||
if(lastSlash != directoryName.size() - 1)
|
if(lastSep != directoryName.size() - 1)
|
||||||
{
|
{
|
||||||
|
// TODO: This assumes that file names will always have a dot in them
|
||||||
|
// and directory names never will; both assumptions are often
|
||||||
|
// right but in general wrong.
|
||||||
size_t extensionStart = directoryName.find_last_of('.');
|
size_t extensionStart = directoryName.find_last_of('.');
|
||||||
if(extensionStart != std::string::npos && extensionStart > lastSlash)
|
if(extensionStart != std::string::npos && extensionStart > lastSep)
|
||||||
{
|
{
|
||||||
directoryName.resize(lastSlash);
|
directoryName.resize(lastSep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
directoryName.resize(directoryName.size() - 1);
|
directoryName.resize(lastSep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return directoryName;
|
return directoryName;
|
||||||
@ -435,7 +445,7 @@ void CVolumeDirectory::WriteEntry(const FSTEntry& entry, u32& fstOffset, u32& na
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
bool ReadFoundFile(const WIN32_FIND_DATA& ffd, CVolumeDirectory::FSTEntry& entry)
|
bool ReadFoundFile(const WIN32_FIND_DATA& ffd, CVolumeDirectory::FSTEntry& entry)
|
||||||
{
|
{
|
||||||
// ignore files starting with a .
|
// ignore files starting with a .
|
||||||
@ -498,6 +508,7 @@ u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntr
|
|||||||
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry)
|
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry)
|
||||||
{
|
{
|
||||||
// TODO - Insert linux stuff here
|
// TODO - Insert linux stuff here
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user