summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--VC2008/MCServer.vcproj8
-rw-r--r--source/Bindings.cpp34
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Entities/Player.cpp3
-rw-r--r--source/Log.cpp9
-rw-r--r--source/OSSupport/File.cpp29
-rw-r--r--source/OSSupport/File.h3
-rw-r--r--source/OSSupport/MakeDir.cpp25
-rw-r--r--source/OSSupport/MakeDir.h16
-rw-r--r--source/World.cpp3
-rw-r--r--source/WorldStorage/NBTChunkSerializer.cpp1
-rw-r--r--source/WorldStorage/WSSAnvil.cpp3
12 files changed, 66 insertions, 70 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 6cc83b4db..57d8cca9e 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -1400,14 +1400,6 @@
>
</File>
<File
- RelativePath="..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\MakeDir.h"
- >
- </File>
- <File
RelativePath="..\source\OSSupport\Semaphore.cpp"
>
</File>
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index c4467eab4..805a9d65d 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 10/09/13 09:38:09.
+** Generated automatically by tolua++-1.0.92 on 10/09/13 09:54:54.
*/
#ifndef __cplusplus
@@ -2686,6 +2686,37 @@ static int tolua_AllToLua_cFile_GetSize00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: CreateFolder of class cFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFile_CreateFolder00
+static int tolua_AllToLua_cFile_CreateFolder00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const AString a_FolderPath = ((const AString) tolua_tocppstring(tolua_S,2,0));
+ {
+ bool tolua_ret = (bool) cFile::CreateFolder(a_FolderPath);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_FolderPath);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CreateFolder'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* function: BlockStringToType */
#ifndef TOLUA_DISABLE_tolua_AllToLua_BlockStringToType00
static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
@@ -29140,6 +29171,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"IsFolder",tolua_AllToLua_cFile_IsFolder00);
tolua_function(tolua_S,"IsFile",tolua_AllToLua_cFile_IsFile00);
tolua_function(tolua_S,"GetSize",tolua_AllToLua_cFile_GetSize00);
+ tolua_function(tolua_S,"CreateFolder",tolua_AllToLua_cFile_CreateFolder00);
tolua_endmodule(tolua_S);
tolua_constant(tolua_S,"E_BLOCK_AIR",E_BLOCK_AIR);
tolua_constant(tolua_S,"E_BLOCK_STONE",E_BLOCK_STONE);
diff --git a/source/Bindings.h b/source/Bindings.h
index 6a5347506..d5e1d731d 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 10/09/13 09:38:10.
+** Generated automatically by tolua++-1.0.92 on 10/09/13 09:54:54.
*/
/* Exported function */
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index 9132bdbd0..d93b45614 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -16,7 +16,6 @@
#include "../Item.h"
#include "../Tracer.h"
#include "../Root.h"
-#include "../OSSupport/MakeDir.h"
#include "../OSSupport/Timer.h"
#include "../MersenneTwister.h"
#include "../Chunk.h"
@@ -1340,7 +1339,7 @@ bool cPlayer::LoadFromDisk()
bool cPlayer::SaveToDisk()
{
- cMakeDir::MakeDir("players");
+ cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));
// create the JSON data
Json::Value JSON_PlayerPosition;
diff --git a/source/Log.cpp b/source/Log.cpp
index c8937c380..fc19595db 100644
--- a/source/Log.cpp
+++ b/source/Log.cpp
@@ -5,7 +5,6 @@
#include <fstream>
#include <ctime>
-#include "OSSupport/MakeDir.h"
#include "OSSupport/IsThread.h"
#if defined(ANDROID_NDK)
@@ -24,9 +23,9 @@ cLog::cLog(const AString & a_FileName )
s_Log = this;
// create logs directory
- cMakeDir::MakeDir("logs");
+ cFile::CreateFolder(FILE_IO_PREFIX + AString("logs"));
- OpenLog( (FILE_IO_PREFIX + std::string("logs/") + a_FileName).c_str() );
+ OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str() );
}
@@ -45,8 +44,10 @@ cLog::~cLog()
cLog* cLog::GetInstance()
{
- if(s_Log)
+ if (s_Log != NULL)
+ {
return s_Log;
+ }
new cLog("log.txt");
return s_Log;
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp
index 16ec00e16..a3733933e 100644
--- a/source/OSSupport/File.cpp
+++ b/source/OSSupport/File.cpp
@@ -310,11 +310,11 @@ bool cFile::Copy(const AString & a_SrcFileName, const AString & a_DstFileName)
bool cFile::IsFolder(const AString & a_Path)
{
#ifdef _WIN32
- DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
- return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
+ DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
+ return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
#else
- struct stat st;
- return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
+ struct stat st;
+ return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
#endif
}
@@ -325,11 +325,11 @@ bool cFile::IsFolder(const AString & a_Path)
bool cFile::IsFile(const AString & a_Path)
{
#ifdef _WIN32
- DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
- return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0));
+ DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
+ return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0));
#else
- struct stat st;
- return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode));
+ struct stat st;
+ return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode));
#endif
}
@@ -351,6 +351,19 @@ int cFile::GetSize(const AString & a_FileName)
+bool cFile::CreateFolder(const AString & a_FolderPath)
+{
+ #ifdef _WIN32
+ return (CreateDirectory(a_FolderPath.c_str(), NULL) != 0);
+ #else
+ return (mkdir(a_FolderPath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0);
+ #endif
+}
+
+
+
+
+
int cFile::Printf(const char * a_Fmt, ...)
{
AString buf;
diff --git a/source/OSSupport/File.h b/source/OSSupport/File.h
index f47bd4041..9fef25ace 100644
--- a/source/OSSupport/File.h
+++ b/source/OSSupport/File.h
@@ -118,6 +118,9 @@ public:
/// Returns the size of the file, or a negative number on error
static int GetSize(const AString & a_FileName);
+ /// Creates a new folder with the specified name. Returns true if successful. Path may be relative or absolute
+ static bool CreateFolder(const AString & a_FolderPath);
+
// tolua_end
int Printf(const char * a_Fmt, ...);
diff --git a/source/OSSupport/MakeDir.cpp b/source/OSSupport/MakeDir.cpp
deleted file mode 100644
index 10ccfe9ec..000000000
--- a/source/OSSupport/MakeDir.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "MakeDir.h"
-
-
-
-
-
-void cMakeDir::MakeDir(const AString & a_Directory)
-{
-#ifdef _WIN32
- SECURITY_ATTRIBUTES Attrib;
- Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
- Attrib.lpSecurityDescriptor = NULL;
- Attrib.bInheritHandle = false;
- ::CreateDirectory( (FILE_IO_PREFIX + a_Directory).c_str(), &Attrib);
-#else
- mkdir( (FILE_IO_PREFIX + a_Directory).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
-#endif
-}
-
-
-
-
diff --git a/source/OSSupport/MakeDir.h b/source/OSSupport/MakeDir.h
deleted file mode 100644
index e66cf1071..000000000
--- a/source/OSSupport/MakeDir.h
+++ /dev/null
@@ -1,16 +0,0 @@
-
-#pragma once
-
-
-
-
-
-class cMakeDir
-{
-public:
- static void MakeDir(const AString & a_Directory);
-};
-
-
-
-
diff --git a/source/World.cpp b/source/World.cpp
index 96a4731d7..bbbe7d382 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -58,7 +58,6 @@
#include "Mobs/Zombie.h"
#include "Mobs/Zombiepigman.h"
-#include "OSSupport/MakeDir.h"
#include "MersenneTwister.h"
#include "Generating/Trees.h"
#include "PluginManager.h"
@@ -261,7 +260,7 @@ cWorld::cWorld(const AString & a_WorldName) :
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
- cMakeDir::MakeDir(m_WorldName.c_str());
+ cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName);
}
diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp
index 11dc50ee3..c9013b1b3 100644
--- a/source/WorldStorage/NBTChunkSerializer.cpp
+++ b/source/WorldStorage/NBTChunkSerializer.cpp
@@ -16,7 +16,6 @@
#include "../ItemGrid.h"
#include "../StringCompression.h"
#include "../Entities/Entity.h"
-#include "../OSSupport/MakeDir.h"
#include "FastNBT.h"
#include "../Entities/FallingBlock.h"
#include "../Entities/Boat.h"
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp
index 4db1ed106..537e2f723 100644
--- a/source/WorldStorage/WSSAnvil.cpp
+++ b/source/WorldStorage/WSSAnvil.cpp
@@ -20,7 +20,6 @@
#include "../Item.h"
#include "../ItemGrid.h"
#include "../StringCompression.h"
-#include "../OSSupport/MakeDir.h"
#include "FastNBT.h"
#include "../Mobs/Monster.h"
#include "../Entities/Boat.h"
@@ -200,7 +199,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
Printf(FileName, "%s/region", m_World->GetName().c_str());
- cMakeDir::MakeDir(FileName);
+ cFile::CreateFolder(FILE_IO_PREFIX + FileName);
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
cMCAFile * f = new cMCAFile(FileName, RegionX, RegionZ);
if (f == NULL)