summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index cddcd1951..173ce6623 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -4,11 +4,12 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <fstream> 8#include <fstream>
8#include <cstdio> 9#include <cstdio>
10#include <cstring>
9#include <string> 11#include <string>
10#include <vector> 12#include <vector>
11#include <string.h>
12 13
13#include "common/common.h" 14#include "common/common.h"
14#include "common/string_util.h" 15#include "common/string_util.h"
@@ -47,7 +48,7 @@ enum {
47namespace FileUtil 48namespace FileUtil
48{ 49{
49 50
50// FileSystem tree node/ 51// FileSystem tree node/
51struct FSTEntry 52struct FSTEntry
52{ 53{
53 bool isDirectory; 54 bool isDirectory;
@@ -85,13 +86,13 @@ bool Delete(const std::string &filename);
85// Deletes a directory filename, returns true on success 86// Deletes a directory filename, returns true on success
86bool DeleteDir(const std::string &filename); 87bool DeleteDir(const std::string &filename);
87 88
88// renames file srcFilename to destFilename, returns true on success 89// renames file srcFilename to destFilename, returns true on success
89bool Rename(const std::string &srcFilename, const std::string &destFilename); 90bool Rename(const std::string &srcFilename, const std::string &destFilename);
90 91
91// copies file srcFilename to destFilename, returns true on success 92// copies file srcFilename to destFilename, returns true on success
92bool Copy(const std::string &srcFilename, const std::string &destFilename); 93bool Copy(const std::string &srcFilename, const std::string &destFilename);
93 94
94// creates an empty file filename, returns true on success 95// creates an empty file filename, returns true on success
95bool CreateEmptyFile(const std::string &filename); 96bool CreateEmptyFile(const std::string &filename);
96 97
97// Scans the directory tree gets, starting from _Directory and adds the 98// Scans the directory tree gets, starting from _Directory and adds the
@@ -110,7 +111,7 @@ void CopyDir(const std::string &source_path, const std::string &dest_path);
110// Set the current directory to given directory 111// Set the current directory to given directory
111bool SetCurrentDir(const std::string &directory); 112bool SetCurrentDir(const std::string &directory);
112 113
113// Returns a pointer to a string with a Dolphin data dir in the user's home 114// Returns a pointer to a string with a Citra data dir in the user's home
114// directory. To be used in "multi-user" mode (that is, installed). 115// directory. To be used in "multi-user" mode (that is, installed).
115const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); 116const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath="");
116 117
@@ -128,8 +129,18 @@ std::string GetBundleDirectory();
128std::string &GetExeDirectory(); 129std::string &GetExeDirectory();
129#endif 130#endif
130 131
131bool WriteStringToFile(bool text_file, const std::string &str, const char *filename); 132size_t WriteStringToFile(bool text_file, const std::string &str, const char *filename);
132bool ReadFileToString(bool text_file, const char *filename, std::string &str); 133size_t ReadFileToString(bool text_file, const char *filename, std::string &str);
134
135/**
136 * Splits the filename into 8.3 format
137 * Loosely implemented following https://en.wikipedia.org/wiki/8.3_filename
138 * @param filename The normal filename to use
139 * @param short_name A 9-char array in which the short name will be written
140 * @param extension A 4-char array in which the extension will be written
141 */
142void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,
143 std::array<char, 4>& extension);
133 144
134// simple wrapper for cstdlib file functions to 145// simple wrapper for cstdlib file functions to
135// hopefully will make error checking easier 146// hopefully will make error checking easier
@@ -142,10 +153,10 @@ public:
142 IOFile(const std::string& filename, const char openmode[]); 153 IOFile(const std::string& filename, const char openmode[]);
143 154
144 ~IOFile(); 155 ~IOFile();
145 156
146 IOFile(IOFile&& other); 157 IOFile(IOFile&& other);
147 IOFile& operator=(IOFile&& other); 158 IOFile& operator=(IOFile&& other);
148 159
149 void Swap(IOFile& other); 160 void Swap(IOFile& other);
150 161
151 bool Open(const std::string& filename, const char openmode[]); 162 bool Open(const std::string& filename, const char openmode[]);