2008-12-08 04:46:09 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
|
|
|
#ifndef _FILEUTIL_H
|
|
|
|
#define _FILEUTIL_H
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2009-02-28 01:26:56 +00:00
|
|
|
/*
|
|
|
|
This namespace has various generic functions related to files and paths.
|
|
|
|
*/
|
2008-12-08 04:46:09 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
// Returns a pointer to a string with the dolphin data dir
|
|
|
|
const char *GetUserDirectory();
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|