2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 21:46:09 -07: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 02:57:34 -06:00
|
|
|
#ifndef _FILEUTIL_H_
|
|
|
|
#define _FILEUTIL_H_
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2009-02-27 18:26:56 -07:00
|
|
|
#include <string.h>
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
2010-02-02 14:56:29 -07:00
|
|
|
// User directory indices for GetUserPath
|
|
|
|
enum {
|
|
|
|
D_USER_IDX,
|
|
|
|
D_GCUSER_IDX,
|
|
|
|
D_WIIUSER_IDX,
|
2010-02-02 20:27:32 -07:00
|
|
|
D_WIIROOT_IDX,
|
2010-02-02 14:56:29 -07:00
|
|
|
D_CONFIG_IDX,
|
|
|
|
D_GAMECONFIG_IDX,
|
|
|
|
D_MAPS_IDX,
|
|
|
|
D_CACHE_IDX,
|
|
|
|
D_SHADERCACHE_IDX,
|
|
|
|
D_SHADERS_IDX,
|
|
|
|
D_STATESAVES_IDX,
|
|
|
|
D_SCREENSHOTS_IDX,
|
|
|
|
D_HIRESTEXTURES_IDX,
|
|
|
|
D_DUMP_IDX,
|
|
|
|
D_DUMPFRAMES_IDX,
|
|
|
|
D_DUMPTEXTURES_IDX,
|
|
|
|
D_DUMPDSP_IDX,
|
|
|
|
D_LOGS_IDX,
|
|
|
|
D_MAILLOGS_IDX,
|
|
|
|
D_WIISYSCONF_IDX,
|
|
|
|
D_WIIMENU_IDX,
|
|
|
|
F_DOLPHINCONFIG_IDX,
|
|
|
|
F_DEBUGGERCONFIG_IDX,
|
|
|
|
F_LOGGERCONFIG_IDX,
|
|
|
|
F_MAINLOG_IDX,
|
|
|
|
F_WIISYSCONF_IDX,
|
|
|
|
F_RAMDUMP_IDX,
|
|
|
|
F_ARAMDUMP_IDX,
|
|
|
|
F_GCSRAM_IDX,
|
|
|
|
};
|
|
|
|
|
2008-12-07 21:46:09 -07:00
|
|
|
namespace File
|
|
|
|
{
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// FileSystem tree node/
|
2008-12-07 21:46:09 -07:00
|
|
|
struct FSTEntry
|
|
|
|
{
|
|
|
|
bool isDirectory;
|
2009-02-27 18:26:56 -07:00
|
|
|
u64 size; // file length or number of entries from children
|
2008-12-07 21:46:09 -07:00
|
|
|
std::string physicalName; // name on disk
|
|
|
|
std::string virtualName; // name in FST names table
|
|
|
|
std::vector<FSTEntry> children;
|
|
|
|
};
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// Returns true if file filename exists
|
2008-12-07 21:46:09 -07:00
|
|
|
bool Exists(const char *filename);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// Returns true if filename is a directory
|
2008-12-07 21:46:09 -07:00
|
|
|
bool IsDirectory(const char *filename);
|
2009-02-27 18:26:56 -07:00
|
|
|
|
|
|
|
// Returns the size of filename (64bit)
|
|
|
|
u64 GetSize(const char *filename);
|
|
|
|
|
|
|
|
// Returns true if successful, or path already exists.
|
2008-12-07 21:46:09 -07:00
|
|
|
bool CreateDir(const char *filename);
|
2009-02-27 18:26:56 -07: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-07 21:46:09 -07:00
|
|
|
bool Delete(const char *filename);
|
2009-02-27 18:26:56 -07:00
|
|
|
|
|
|
|
// Deletes a directory filename, returns true on success
|
2008-12-07 21:46:09 -07:00
|
|
|
bool DeleteDir(const char *filename);
|
2009-02-27 18:26:56 -07:00
|
|
|
|
|
|
|
// renames file srcFilename to destFilename, returns true on success
|
2008-12-07 21:46:09 -07:00
|
|
|
bool Rename(const char *srcFilename, const char *destFilename);
|
2009-02-27 18:26:56 -07:00
|
|
|
|
|
|
|
// copies file srcFilename to destFilename, returns true on success
|
2008-12-07 21:46:09 -07:00
|
|
|
bool Copy(const char *srcFilename, const char *destFilename);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// creates an empty file filename, returns true on success
|
2008-12-07 21:46:09 -07:00
|
|
|
bool CreateEmptyFile(const char *filename);
|
2009-06-09 13:40:47 -06:00
|
|
|
|
2009-02-27 18:26:56 -07: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);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// deletes the given directory and anything under it. Returns true on success.
|
|
|
|
bool DeleteDirRecursively(const char *directory);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
|
|
|
// Returns the current directory
|
|
|
|
std::string GetCurrentDir();
|
|
|
|
|
2010-05-11 22:26:32 -06:00
|
|
|
// Create directory and copy contents (does not overwrite existing files)
|
2010-02-02 14:56:29 -07:00
|
|
|
void CopyDir(const char *source_path, const char *dest_path);
|
|
|
|
|
2009-02-27 18:26:56 -07:00
|
|
|
// Set the current directory to given directory
|
2009-07-30 01:09:26 -06:00
|
|
|
bool SetCurrentDir(const char *directory);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-28 16:21:51 -07: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).
|
2010-02-02 14:56:29 -07:00
|
|
|
const char *GetUserPath(int DirIDX);
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-28 16:21:51 -07:00
|
|
|
// Returns the path to where the plugins are
|
|
|
|
std::string GetPluginsDirectory();
|
2009-08-06 00:18:22 -06:00
|
|
|
|
2009-02-28 16:21:51 -07:00
|
|
|
// Returns the path to where the sys file are
|
|
|
|
std::string GetSysDirectory();
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
std::string GetBundleDirectory();
|
|
|
|
#endif
|
|
|
|
|
2009-04-12 07:12:42 -06:00
|
|
|
bool WriteStringToFile(bool text_file, const std::string &str, const char *filename);
|
2009-04-25 04:38:26 -06:00
|
|
|
bool ReadFileToString(bool text_file, const char *filename, std::string &str);
|
2009-04-12 04:21:40 -06:00
|
|
|
|
2008-12-07 21:46:09 -07:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|