@@ -42,7 +42,7 @@ liblol_headers = \ | |||||
lol/math/remez.h lol/math/math.h lol/math/geometry.h \ | lol/math/remez.h lol/math/math.h lol/math/geometry.h \ | ||||
\ | \ | ||||
lol/sys/sys.h \ | lol/sys/sys.h \ | ||||
lol/sys/init.h lol/sys/thread.h lol/sys/timer.h \ | |||||
lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/timer.h \ | |||||
\ | \ | ||||
lol/image/image.h \ | lol/image/image.h \ | ||||
lol/image/color.h \ | lol/image/color.h \ | ||||
@@ -90,7 +90,7 @@ liblol_sources = \ | |||||
\ | \ | ||||
mesh/mesh.cpp mesh/mesh.h \ | mesh/mesh.cpp mesh/mesh.h \ | ||||
\ | \ | ||||
sys/init.cpp sys/timer.cpp \ | |||||
sys/init.cpp sys/timer.cpp sys/file.cpp \ | |||||
sys/threadbase.h \ | sys/threadbase.h \ | ||||
\ | \ | ||||
image/image.cpp image/image.h image/image-private.h \ | image/image.cpp image/image.h image/image-private.h \ | ||||
@@ -0,0 +1,54 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://www.wtfpl.net/ for more details. | |||||
// | |||||
// | |||||
// File and buffer reading | |||||
// ----------------------- | |||||
// | |||||
#if !defined __LOL_SYS_FILE_H__ | |||||
#define __LOL_SYS_FILE_H__ | |||||
#include <stdint.h> | |||||
namespace lol | |||||
{ | |||||
struct FileAccess | |||||
{ | |||||
enum Value | |||||
{ | |||||
Read = 0, | |||||
Write, | |||||
} | |||||
m_value; | |||||
inline FileAccess(Value v) : m_value(v) {} | |||||
inline operator Value() { return m_value; } | |||||
}; | |||||
class File | |||||
{ | |||||
public: | |||||
inline File() : m_data(0) {} | |||||
inline ~File() {} | |||||
void Open(String const &file, FileAccess mode); | |||||
String const &ReadString(); | |||||
void Close(); | |||||
private: | |||||
class FileData *m_data; | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_SYS_FILE_H__ | |||||
@@ -46,8 +46,8 @@ extern void Init(int argc, char *argv[], | |||||
String const &projectdir = LOL_CONFIG_PROJECTDIR, | String const &projectdir = LOL_CONFIG_PROJECTDIR, | ||||
String const &solutiondir = LOL_CONFIG_SOLUTIONDIR); | String const &solutiondir = LOL_CONFIG_SOLUTIONDIR); | ||||
extern void SetDataDir(char const *dir); | |||||
extern char const *GetDataDir(); | |||||
extern void SetDataDir(String const &dir); | |||||
extern String const &GetDataDir(); | |||||
} /* namespace System */ | } /* namespace System */ | ||||
@@ -12,6 +12,7 @@ | |||||
#define __LOL_SYS_SYS_H__ | #define __LOL_SYS_SYS_H__ | ||||
#include <lol/sys/init.h> | #include <lol/sys/init.h> | ||||
#include <lol/sys/file.h> | |||||
#include <lol/sys/thread.h> | #include <lol/sys/thread.h> | ||||
#include <lol/sys/timer.h> | #include <lol/sys/timer.h> | ||||
@@ -294,6 +294,7 @@ | |||||
<ClCompile Include="sampler.cpp" /> | <ClCompile Include="sampler.cpp" /> | ||||
<ClCompile Include="scene.cpp" /> | <ClCompile Include="scene.cpp" /> | ||||
<ClCompile Include="sprite.cpp" /> | <ClCompile Include="sprite.cpp" /> | ||||
<ClCompile Include="sys\file.cpp" /> | |||||
<ClCompile Include="sys\init.cpp" /> | <ClCompile Include="sys\init.cpp" /> | ||||
<ClCompile Include="sys\timer.cpp" /> | <ClCompile Include="sys\timer.cpp" /> | ||||
<ClCompile Include="text.cpp" /> | <ClCompile Include="text.cpp" /> | ||||
@@ -605,6 +606,7 @@ | |||||
<ClInclude Include="lol\math\real.h" /> | <ClInclude Include="lol\math\real.h" /> | ||||
<ClInclude Include="lol\math\remez.h" /> | <ClInclude Include="lol\math\remez.h" /> | ||||
<ClInclude Include="lol\math\vector.h" /> | <ClInclude Include="lol\math\vector.h" /> | ||||
<ClInclude Include="lol\sys\file.h" /> | |||||
<ClInclude Include="lol\sys\init.h" /> | <ClInclude Include="lol\sys\init.h" /> | ||||
<ClInclude Include="lol\sys\sys.h" /> | <ClInclude Include="lol\sys\sys.h" /> | ||||
<ClInclude Include="lol\sys\thread.h" /> | <ClInclude Include="lol\sys\thread.h" /> | ||||
@@ -0,0 +1,27 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://www.wtfpl.net/ for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include "core.h" | |||||
namespace lol | |||||
{ | |||||
class FileData | |||||
{ | |||||
friend class File; | |||||
}; | |||||
} /* namespace lol */ | |||||
@@ -92,7 +92,7 @@ void Init(int argc, char *argv[], | |||||
} | } | ||||
Log::Debug("binary dir: %s\n", &binarydir[0]); | Log::Debug("binary dir: %s\n", &binarydir[0]); | ||||
Log::Debug("root dir: %s\n", GetDataDir()); | |||||
Log::Debug("root dir: %s\n", &GetDataDir()[0]); | |||||
} | } | ||||
/* | /* | ||||
@@ -101,17 +101,16 @@ void Init(int argc, char *argv[], | |||||
String data_dir = ""; | String data_dir = ""; | ||||
void SetDataDir(char const *dir) | |||||
void SetDataDir(String const &dir) | |||||
{ | { | ||||
data_dir = dir; | data_dir = dir; | ||||
} | } | ||||
char const *GetDataDir() | |||||
String const &GetDataDir() | |||||
{ | { | ||||
return &data_dir[0]; | |||||
return data_dir; | |||||
} | } | ||||
} /* namespace System */ | } /* namespace System */ | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||