Selaa lähdekoodia

sys: create an empty File class.

legacy
Sam Hocevar sam 11 vuotta sitten
vanhempi
commit
c7767c6c64
7 muutettua tiedostoa jossa 92 lisäystä ja 9 poistoa
  1. +2
    -2
      src/Makefile.am
  2. +54
    -0
      src/lol/sys/file.h
  3. +2
    -2
      src/lol/sys/init.h
  4. +1
    -0
      src/lol/sys/sys.h
  5. +2
    -0
      src/lolcore.vcxproj
  6. +27
    -0
      src/sys/file.cpp
  7. +4
    -5
      src/sys/init.cpp

+ 2
- 2
src/Makefile.am Näytä tiedosto

@@ -42,7 +42,7 @@ liblol_headers = \
lol/math/remez.h lol/math/math.h lol/math/geometry.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/color.h \
@@ -90,7 +90,7 @@ liblol_sources = \
\
mesh/mesh.cpp mesh/mesh.h \
\
sys/init.cpp sys/timer.cpp \
sys/init.cpp sys/timer.cpp sys/file.cpp \
sys/threadbase.h \
\
image/image.cpp image/image.h image/image-private.h \


+ 54
- 0
src/lol/sys/file.h Näytä tiedosto

@@ -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__


+ 2
- 2
src/lol/sys/init.h Näytä tiedosto

@@ -46,8 +46,8 @@ extern void Init(int argc, char *argv[],
String const &projectdir = LOL_CONFIG_PROJECTDIR,
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 */



+ 1
- 0
src/lol/sys/sys.h Näytä tiedosto

@@ -12,6 +12,7 @@
#define __LOL_SYS_SYS_H__

#include <lol/sys/init.h>
#include <lol/sys/file.h>
#include <lol/sys/thread.h>
#include <lol/sys/timer.h>



+ 2
- 0
src/lolcore.vcxproj Näytä tiedosto

@@ -294,6 +294,7 @@
<ClCompile Include="sampler.cpp" />
<ClCompile Include="scene.cpp" />
<ClCompile Include="sprite.cpp" />
<ClCompile Include="sys\file.cpp" />
<ClCompile Include="sys\init.cpp" />
<ClCompile Include="sys\timer.cpp" />
<ClCompile Include="text.cpp" />
@@ -605,6 +606,7 @@
<ClInclude Include="lol\math\real.h" />
<ClInclude Include="lol\math\remez.h" />
<ClInclude Include="lol\math\vector.h" />
<ClInclude Include="lol\sys\file.h" />
<ClInclude Include="lol\sys\init.h" />
<ClInclude Include="lol\sys\sys.h" />
<ClInclude Include="lol\sys\thread.h" />


+ 27
- 0
src/sys/file.cpp Näytä tiedosto

@@ -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 */


+ 4
- 5
src/sys/init.cpp Näytä tiedosto

@@ -92,7 +92,7 @@ void Init(int argc, char *argv[],
}

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 = "";

void SetDataDir(char const *dir)
void SetDataDir(String const &dir)
{
data_dir = dir;
}

char const *GetDataDir()
String const &GetDataDir()
{
return &data_dir[0];
return data_dir;
}


} /* namespace System */

} /* namespace lol */


Ladataan…
Peruuta
Tallenna