2009-03-28 08:57:34 +00:00
|
|
|
// Copyright (C) 2003-2009 Dolphin Project.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
#ifndef _FILEUTIL_H_
|
|
|
|
#define _FILEUTIL_H_
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2009-02-28 01:26:56 +00:00
|
|
|
#include <string.h>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
|
|
|
namespace File
|
|
|
|
{
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// FileSystem tree node/
|
2008-12-08 04:46:09 +00:00
|
|
|
struct FSTEntry
|
|
|
|
{
|
|
|
|
bool isDirectory;
|
2009-02-28 01:26:56 +00:00
|
|
|
u64 size; // file length or number of entries from children
|
2008-12-08 04:46:09 +00:00
|
|
|
std::string physicalName; // name on disk
|
|
|
|
std::string virtualName; // name in FST names table
|
|
|
|
std::vector<FSTEntry> children;
|
|
|
|
};
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Returns true if file filename exists
|
2008-12-08 04:46:09 +00:00
|
|
|
bool Exists(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Returns true if filename is a directory
|
2008-12-08 04:46:09 +00:00
|
|
|
bool IsDirectory(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Returns the size of filename (64bit)
|
|
|
|
u64 GetSize(const char *filename);
|
|
|
|
|
|
|
|
// Returns true if successful, or path already exists.
|
2008-12-08 04:46:09 +00:00
|
|
|
bool CreateDir(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Creates the full path of fullPath returns true on success
|
|
|
|
bool CreateFullPath(const char *fullPath);
|
|
|
|
|
|
|
|
// Deletes a given filename, return true on success
|
|
|
|
// Doesn't supports deleting a directory
|
2008-12-08 04:46:09 +00:00
|
|
|
bool Delete(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Deletes a directory filename, returns true on success
|
2008-12-08 04:46:09 +00:00
|
|
|
bool DeleteDir(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// renames file srcFilename to destFilename, returns true on success
|
2008-12-08 04:46:09 +00:00
|
|
|
bool Rename(const char *srcFilename, const char *destFilename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// copies file srcFilename to destFilename, returns true on success
|
2008-12-08 04:46:09 +00:00
|
|
|
bool Copy(const char *srcFilename, const char *destFilename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// creates an empty file filename, returns true on success
|
2008-12-08 04:46:09 +00:00
|
|
|
bool CreateEmptyFile(const char *filename);
|
2009-02-28 01:26:56 +00:00
|
|
|
|
|
|
|
// Scans the directory tree gets, starting from _Directory and adds the
|
|
|
|
// results into parentEntry. Returns the number of files+directories found
|
|
|
|
u32 ScanDirectoryTree(const char *directory, FSTEntry& parentEntry);
|
|
|
|
|
|
|
|
// deletes the given directory and anything under it. Returns true on success.
|
|
|
|
bool DeleteDirRecursively(const char *directory);
|
|
|
|
|
|
|
|
// Returns the current directory, caller should free
|
|
|
|
const char *GetCurrentDirectory();
|
|
|
|
|
|
|
|
// Set the current directory to given directory
|
|
|
|
bool SetCurrentDirectory(const char *directory);
|
|
|
|
|
2009-02-28 23:21:51 +00:00
|
|
|
|
|
|
|
// Returns a pointer to a string with a Dolphin data dir in the user's home
|
|
|
|
// directory. To be used in "multi-user" mode (that is, installed).
|
2009-02-28 01:26:56 +00:00
|
|
|
const char *GetUserDirectory();
|
|
|
|
|
2009-02-28 23:21:51 +00:00
|
|
|
// Returns the path to where the plugins are
|
|
|
|
std::string GetPluginsDirectory();
|
|
|
|
|
|
|
|
// Returns the path to where the sys file are
|
|
|
|
std::string GetSysDirectory();
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2009-03-09 10:43:56 +00:00
|
|
|
|
|
|
|
char *GetConfigDirectory();
|
|
|
|
|
2009-02-28 23:21:51 +00:00
|
|
|
std::string GetBundleDirectory();
|
|
|
|
#endif
|
|
|
|
|
2009-04-12 13:12:42 +00:00
|
|
|
bool WriteStringToFile(bool text_file, const std::string &str, const char *filename);
|
2009-04-25 10:38:26 +00:00
|
|
|
bool ReadFileToString(bool text_file, const char *filename, std::string &str);
|
2009-04-12 10:21:40 +00:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|