mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-02 02:52:30 +02:00
Changed File from a class into a namespace, since all its methods were static.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@647 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
5a3aee5118
commit
851dbcd7d6
@ -30,7 +30,10 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
bool File::Exists(const char *filename)
|
||||
namespace File
|
||||
{
|
||||
|
||||
bool Exists(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
|
||||
@ -41,7 +44,7 @@ bool File::Exists(const char *filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::IsDirectory(const char *filename)
|
||||
bool IsDirectory(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
@ -55,11 +58,11 @@ bool File::IsDirectory(const char *filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::Delete(const char *filename)
|
||||
bool Delete(const char *filename)
|
||||
{
|
||||
if (!File::Exists(filename))
|
||||
if (!Exists(filename))
|
||||
return false;
|
||||
if (File::IsDirectory(filename))
|
||||
if (IsDirectory(filename))
|
||||
return false;
|
||||
#ifdef _WIN32
|
||||
DeleteFile(filename);
|
||||
@ -78,7 +81,7 @@ std::string SanitizePath(const char *filename)
|
||||
return copy;
|
||||
}
|
||||
|
||||
void File::Launch(const char *filename)
|
||||
void Launch(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string win_filename = SanitizePath(filename);
|
||||
@ -93,7 +96,7 @@ void File::Launch(const char *filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
void File::Explore(const char *path)
|
||||
void Explore(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string win_path = SanitizePath(path);
|
||||
@ -109,7 +112,7 @@ void File::Explore(const char *path)
|
||||
}
|
||||
|
||||
// Returns true if successful, or path already exists.
|
||||
bool File::CreateDir(const char *path)
|
||||
bool CreateDir(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (::CreateDirectory(path, NULL))
|
||||
@ -128,7 +131,8 @@ bool File::CreateDir(const char *path)
|
||||
|
||||
int err = errno;
|
||||
|
||||
if (err == EEXIST) {
|
||||
if (err == EEXIST)
|
||||
{
|
||||
PanicAlert("%s already exists", path);
|
||||
return true;
|
||||
}
|
||||
@ -139,7 +143,8 @@ bool File::CreateDir(const char *path)
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string File::GetUserDirectory() {
|
||||
std::string GetUserDirectory()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char path[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
|
||||
@ -155,7 +160,7 @@ std::string File::GetUserDirectory() {
|
||||
#endif
|
||||
}
|
||||
|
||||
u64 File::GetSize(const char *filename)
|
||||
u64 GetSize(const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
@ -163,3 +168,5 @@ u64 File::GetSize(const char *filename)
|
||||
fclose(f);
|
||||
return pos;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -22,17 +22,18 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class File
|
||||
namespace File
|
||||
{
|
||||
public:
|
||||
static bool Exists(const char *filename);
|
||||
static void Launch(const char *filename);
|
||||
static void Explore(const char *path);
|
||||
static bool IsDirectory(const char *filename);
|
||||
static bool CreateDir(const char *filename);
|
||||
static bool Delete(const char *filename);
|
||||
static u64 GetSize(const char *filename);
|
||||
static std::string GetUserDirectory();
|
||||
};
|
||||
|
||||
bool Exists(const char *filename);
|
||||
void Launch(const char *filename);
|
||||
void Explore(const char *path);
|
||||
bool IsDirectory(const char *filename);
|
||||
bool CreateDir(const char *filename);
|
||||
bool Delete(const char *filename);
|
||||
u64 GetSize(const char *filename);
|
||||
std::string GetUserDirectory();
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user