From d3477eedc113a2c126f36f41384b8921d610906a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 8 Feb 2008 19:24:12 +0000 Subject: updated filesystem, removed inifile, updated game and tga loader minor cleanups --- src/filesystem/filesystem.cc | 59 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 10 deletions(-) (limited to 'src/filesystem/filesystem.cc') diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc index da80ea5..f34ac42 100644 --- a/src/filesystem/filesystem.cc +++ b/src/filesystem/filesystem.cc @@ -5,15 +5,22 @@ */ // project headers + #include "filesystem/filesystem.h" +#include "filesystem/diskfile.h" +#include "filesystem/file.h" #include "sys/sys.h" -std::string filesystem::datadir = ""; -std::string filesystem::homedir = ""; -std::string filesystem::basedir = ""; -std::string filesystem::moddir = ""; +namespace filesystem +{ + +std::string datadir = ""; +std::string homedir = ""; +std::string basedir = ""; +std::string moddir = ""; +std::string writedir = ""; -void filesystem::init() +void init() { con_print << "Initializing filesystem..." << std::endl; @@ -27,14 +34,46 @@ void filesystem::init() // FIXME win32 homedir = getenv("HOME"); homedir = homedir + "/.osirion/"; - Path::create(homedir); - Path::create(homedir+basedir); - if (moddir.size() && !Path::exists(homedir+moddir)) - Path::create(homedir+moddir); + + sys::mkdir(homedir); + sys::mkdir(homedir+basedir); + + writedir = homedir; + if (moddir.size()) { + writedir.append(moddir); + } else + writedir.append(basedir); + + sys::mkdir(writedir); + + con_print << " files are created in " << writedir << std::endl; } -void filesystem::shutdown() +void shutdown() { con_print << "Shutting down filesystem..." << std::endl; } +File *open(const char *filename) +{ + // for now, File is always a DiskFile + DiskFile *f = new DiskFile(); + if (!f->open(filename)) { + delete f; + f = 0; + return 0; + } + return f; +} + +void close(File *file) +{ + if (!file) + return; + + file->close(); + delete file; +} + +} + -- cgit v1.2.3