summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-04-12 10:21:40 +0000
committerhrydgard <hrydgard@gmail.com>2009-04-12 10:21:40 +0000
commite8b9e93465ec9e78de823c1480439f9efb2a8012 (patch)
treeb8e70742317f9e558111d1324ecdc824df1837ad /Source/Core/Common/Src/FileUtil.cpp
parent2b2c2afa3cb7f5e556f719069052feb703b2c1e6 (diff)
DSP: Move the LLE core to a library. Added DSP assembler from gdtool, start cleaning it up. Create a new program called "DSPTool" which will become a more up to date replacement for gdtool from the devkitpro, automatically incorporating all our findings as we make them. This program depends on the new library. It can *ALMOST* roundtrip (asm->disasm->asm) hermes' DSP mixer at this point. Sorry about the unfinished Sconscript work - I'll fix it soon if nobody else does it first.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2955 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index fada9db8e8..05030deb59 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -601,4 +601,35 @@ const char *GetUserDirectory()
return path;
}
+bool WriteStringToFile(bool text_file, const char *str, const char *filename)
+{
+ FILE *f = fopen(filename, text_file ? "w" : "wb");
+ if (!f)
+ return false;
+ size_t len = strlen(str);
+ if (len != fwrite(str, 1, strlen(str), f))
+ {
+ fclose(f);
+ return false;
+ }
+ fclose(f);
+ return true;
+}
+
+bool ReadStringFromFile(bool text_file, const char *filename, std::string *str)
+{
+ FILE *f = fopen(filename, text_file ? "r" : "rb");
+ if (!f)
+ return false;
+ fseek(f, 0, SEEK_END);
+ size_t len = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ char *buf = new char[len + 1];
+ buf[fread(buf, 1, len, f)] = 0;
+ *str = std::string(buf);
+ fclose(f);
+ delete [] buf;
+ return true;
+}
+
} // namespace