Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-03 18:53:40 +0000
committerStijn Buys <ingar@osirion.org>2008-02-03 18:53:40 +0000
commit43b994017a560a2fa97894ebfe121375d6614b6f (patch)
treebebdf504c283a797707f92d46e7d3ed8b5100a9d /src/filesystem
parent6011bbb179f72a370411960eafdbbc98e6607f05 (diff)
basic client console
Diffstat (limited to 'src/filesystem')
-rw-r--r--src/filesystem/Makefile.am4
-rw-r--r--src/filesystem/file.cc6
-rw-r--r--src/filesystem/file.h6
-rw-r--r--src/filesystem/filesystem.cc4
-rw-r--r--src/filesystem/vfile.cc24
-rw-r--r--src/filesystem/vfile.h31
6 files changed, 71 insertions, 4 deletions
diff --git a/src/filesystem/Makefile.am b/src/filesystem/Makefile.am
index a490cd3..65540f1 100644
--- a/src/filesystem/Makefile.am
+++ b/src/filesystem/Makefile.am
@@ -1,9 +1,9 @@
METASOURCES = AUTO
-libfilesystem_la_SOURCES = file.cc filesystem.cc inifile.cc path.cc
+libfilesystem_la_SOURCES = file.cc filesystem.cc inifile.cc path.cc vfile.cc
libfilesystem_la_LDFLAGS = -avoid-version -no-undefined
libfilesystem_la_LIBADD = $(top_builddir)/src/sys/libsys.la
noinst_LTLIBRARIES = libfilesystem.la
-noinst_HEADERS = file.h filesystem.h inifile.h path.h
+noinst_HEADERS = file.h filesystem.h inifile.h path.h vfile.h
INCLUDES = -I$(top_srcdir)/src
diff --git a/src/filesystem/file.cc b/src/filesystem/file.cc
index cd6ae1b..1203d5a 100644
--- a/src/filesystem/file.cc
+++ b/src/filesystem/file.cc
@@ -17,6 +17,8 @@ File::~File() {}
void File::open(const char * filename, ios_base::openmode mode) {
file_name.assign(filename);
std::string fn;
+
+ real_name.clear();
// if moddir is set, try the mods subdir first
if (moddir.size()) {
@@ -26,6 +28,7 @@ void File::open(const char * filename, ios_base::openmode mode) {
fn.append(filename);
std::ifstream::open(fn.c_str(), mode);
if (this->is_open()) {
+ real_name = fn;
con_debug << "File opened " << fn << std::endl;
return;
}
@@ -36,6 +39,7 @@ void File::open(const char * filename, ios_base::openmode mode) {
std::ifstream::open(fn.c_str(), mode);
if (this->is_open()) {
con_debug << "File opened " << fn << std::endl;
+ real_name = fn;
return;
}
}
@@ -47,6 +51,7 @@ void File::open(const char * filename, ios_base::openmode mode) {
std::ifstream::open(fn.c_str(), mode);
if (this->is_open()) {
con_debug << "File opened " << fn << std::endl;
+ real_name = fn;
return;
}
@@ -60,6 +65,7 @@ void File::open(const char * filename, ios_base::openmode mode) {
con_warn << "Could not open " << filename << std::endl;
} else {
con_debug << "File opened " << fn << std::endl;
+ real_name = fn;
}
}
diff --git a/src/filesystem/file.h b/src/filesystem/file.h
index aaafd01..ba392de 100644
--- a/src/filesystem/file.h
+++ b/src/filesystem/file.h
@@ -26,9 +26,15 @@ public:
inline std::string name() {
return file_name;
}
+
+ /// current full path
+ inline std::string path() {
+ return real_name;
+ }
private:
std::string file_name;
+ std::string real_name;
}
; // class File
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index b720198..5d3ed40 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -14,7 +14,7 @@ std::string filesystem::basedir = "";
std::string filesystem::moddir = "";
void filesystem::init() {
- con_debug << "Initializing filesystem..." << std::endl;
+ con_print << "Initializing filesystem..." << std::endl;
// FIXME datadir should by set by ./configure and read from config.h
@@ -33,6 +33,6 @@ void filesystem::init() {
}
void filesystem::shutdown() {
- con_debug << "Shutting down filesystem..." << std::endl;
+ con_print << "Shutting down filesystem..." << std::endl;
}
diff --git a/src/filesystem/vfile.cc b/src/filesystem/vfile.cc
new file mode 100644
index 0000000..9fcb2b3
--- /dev/null
+++ b/src/filesystem/vfile.cc
@@ -0,0 +1,24 @@
+/*
+ filesystem/vfile.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+// project headers
+#include "filesystem/vfile.h"
+
+namespace filesystem
+{
+
+std::string VFile::find(const char *filename)
+{
+ return std::string();
+}
+
+
+bool VFile::exists(const char *filename)
+{
+ return (find(filename).size() == 0);
+}
+
+}
diff --git a/src/filesystem/vfile.h b/src/filesystem/vfile.h
new file mode 100644
index 0000000..a64dbc6
--- /dev/null
+++ b/src/filesystem/vfile.h
@@ -0,0 +1,31 @@
+/*
+ filesystem/vfile.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_FILESYSTEM_VFILE_H__
+#define __INCLUDED_FILESYSTEM_VFILE_H__
+
+// project headers
+#include "filesystem/filesystem.h"
+
+namespace filesystem {
+
+/// a file in the virtual file system
+class VFile {
+
+public:
+ /// search the path for a file in the virtual
+ /** If the file can not be found in any of the data directories,
+ * an empty string will be returned
+ */
+ static std::string find(const char *filename);
+
+ /// returns true if a file exists in the virtual filesystem
+ static bool exists(const char *filename);
+};
+
+}
+
+#endif //__INCLUDED_FILESYSTEM_VFILE_H__