mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Changed: #1023 Use a standard application path for writing files
This commit is contained in:
parent
f9e5950126
commit
148f1659c8
7 changed files with 81 additions and 46 deletions
|
@ -65,7 +65,7 @@ ENDIF(COMMAND cmake_policy)
|
|||
# Set default config options
|
||||
|
||||
NL_SETUP_DEFAULT_OPTIONS()
|
||||
NL_SETUP_PREFIX_PATHS()
|
||||
RYZOM_SETUP_PREFIX_PATHS()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Override default options
|
||||
|
@ -114,6 +114,11 @@ IF(FINAL_VERSION)
|
|||
ADD_DEFINITIONS(-DFINAL_VERSION=1)
|
||||
ENDIF(FINAL_VERSION)
|
||||
|
||||
# config.h configuration and use by projects
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
|
||||
|
||||
ADD_SUBDIRECTORY(common)
|
||||
|
||||
IF(WITH_CLIENT)
|
||||
|
|
|
@ -131,50 +131,41 @@ MACRO(NL_SETUP_BUILD_FLAGS)
|
|||
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${NL_RELEASEDEBUG_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
ENDMACRO(NL_SETUP_BUILD_FLAGS)
|
||||
|
||||
MACRO(NL_SETUP_PREFIX_PATHS)
|
||||
MACRO(RYZOM_SETUP_PREFIX_PATHS)
|
||||
## Allow override of install_prefix/etc path.
|
||||
IF(NOT NL_ETC_PREFIX)
|
||||
IF(NOT RYZOM_ETC_PREFIX)
|
||||
IF(WIN32)
|
||||
SET(NL_ETC_PREFIX "../etc" CACHE PATH "Installation path for configurations")
|
||||
SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
|
||||
ELSE(WIN32)
|
||||
SET(NL_ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" CACHE PATH "Installation path for configurations")
|
||||
SET(RYZOM_ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc/ryzom" CACHE PATH "Installation path for configurations")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT NL_ETC_PREFIX)
|
||||
ENDIF(NOT RYZOM_ETC_PREFIX)
|
||||
|
||||
## Allow override of install_prefix/share path.
|
||||
IF(NOT NL_SHARE_PREFIX)
|
||||
IF(NOT RYZOM_SHARE_PREFIX)
|
||||
IF(WIN32)
|
||||
SET(NL_SHARE_PREFIX "../share" CACHE PATH "Installation path for data.")
|
||||
SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
|
||||
ELSE(WIN32)
|
||||
SET(NL_SHARE_PREFIX "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Installation path for data.")
|
||||
SET(RYZOM_SHARE_PREFIX "${CMAKE_INSTALL_PREFIX}/share/ryzom" CACHE PATH "Installation path for data.")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT NL_SHARE_PREFIX)
|
||||
|
||||
## Allow override of install_prefix/sbin path.
|
||||
IF(NOT NL_SBIN_PREFIX)
|
||||
IF(NOT RYZOM_SBIN_PREFIX)
|
||||
IF(WIN32)
|
||||
SET(NL_SBIN_PREFIX "../sbin" CACHE PATH "Installation path for admin tools and services.")
|
||||
SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
|
||||
ELSE(WIN32)
|
||||
SET(NL_SBIN_PREFIX "${CMAKE_INSTALL_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.")
|
||||
SET(RYZOM_SBIN_PREFIX "${CMAKE_INSTALL_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT NL_SBIN_PREFIX)
|
||||
ENDIF(NOT RYZOM_SBIN_PREFIX)
|
||||
|
||||
## Allow override of install_prefix/bin path.
|
||||
IF(NOT NL_BIN_PREFIX)
|
||||
IF(NOT RYZOM_BIN_PREFIX)
|
||||
IF(WIN32)
|
||||
SET(NL_BIN_PREFIX "../bin" CACHE PATH "Installation path for tools and applications.")
|
||||
SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
|
||||
ELSE(WIN32)
|
||||
SET(NL_BIN_PREFIX "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation path for tools and applications.")
|
||||
SET(RYZOM_BIN_PREFIX "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation path for client and tools.")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT NL_BIN_PREFIX)
|
||||
ENDIF(NOT RYZOM_BIN_PREFIX)
|
||||
|
||||
## Allow override of install_prefix/bin path.
|
||||
IF(NOT NL_LOG_PREFIX)
|
||||
IF(WIN32)
|
||||
SET(NL_LOG_PREFIX "../var/log" CACHE PATH "Installation path for tools and applications.")
|
||||
ELSE(WIN32)
|
||||
SET(NL_LOG_PREFIX "${CMAKE_INSTALL_PREFIX}/var/log" CACHE PATH "Installation path for tools and applications.")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT NL_LOG_PREFIX)
|
||||
|
||||
ENDMACRO(NL_SETUP_PREFIX_PATHS)
|
||||
ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
|
||||
|
|
|
@ -99,4 +99,4 @@ IF(WITH_PCH)
|
|||
ADD_NATIVE_PRECOMPILED_HEADER(ryzom_client ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp)
|
||||
ENDIF(WITH_PCH)
|
||||
|
||||
INSTALL(TARGETS ryzom_client RUNTIME DESTINATION bin COMPONENT client BUNDLE DESTINATION /Applications)
|
||||
INSTALL(TARGETS ryzom_client RUNTIME DESTINATION ${RYZOM_BIN_PREFIX} COMPONENT client BUNDLE DESTINATION /Applications)
|
||||
|
|
|
@ -345,13 +345,15 @@ int main(int argc, char **argv)
|
|||
// init the Nel context
|
||||
CApplicationContext *appContext = new CApplicationContext;
|
||||
|
||||
#ifdef CHANGE_CURRENT_PATH
|
||||
// if client_default.cfg is not in current directory, use application default directory
|
||||
if (!CFile::isExists("client_default.cfg"))
|
||||
{
|
||||
std::string currentPath = CFile::getApplicationDirectory("Ryzom");
|
||||
|
||||
if (!CFile::isExists(currentPath)) CFile::createDirectory(currentPath);
|
||||
|
||||
CPath::setCurrentPath(currentPath);
|
||||
#endif // CHANGE_CURRENT_PATH
|
||||
}
|
||||
|
||||
// temporary buffer to store Ryzom full path
|
||||
char filename[1024];
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
#include "game_share/time_weather_season/time_and_season.h"
|
||||
#include "game_share/ryzom_version.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
///////////
|
||||
// MACRO //
|
||||
///////////
|
||||
|
@ -1967,21 +1971,41 @@ void CClientConfig::init(const string &configFileName)
|
|||
{
|
||||
if(!CFile::fileExists(configFileName))
|
||||
{
|
||||
#if defined(NL_ETC_PREFIX) && defined(NL_SHARE_PREFIX)
|
||||
nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
|
||||
std::string defaultConfigFileName = "client_default.cfg";
|
||||
bool found = false;
|
||||
|
||||
if (CFile::isExists(defaultConfigFileName)) found = true;
|
||||
|
||||
#ifdef RYZOM_ETC_PREFIX
|
||||
if (!found)
|
||||
{
|
||||
defaultConfigFileName = std::string(RYZOM_ETC_PREFIX"/") + defaultConfigFileName;
|
||||
if (CFile::isExists(defaultConfigFileName)) found = true;
|
||||
}
|
||||
#endif // RYZOM_ETC_PREFIX
|
||||
|
||||
if (found)
|
||||
{
|
||||
// create the basic .cfg that link the default one
|
||||
FILE *fp = fopen(configFileName.c_str(), "w");
|
||||
if (fp == NULL)
|
||||
{
|
||||
nlerror ("CFG::init: Can't create config file '%s'", configFileName.c_str());
|
||||
}
|
||||
fprintf(fp, "RootConfigFilename = \"%s/client_default.cfg\";\n", NL_ETC_PREFIX);
|
||||
fprintf(fp, "DataPath = { \"%s/data\" };\n", NL_SHARE_PREFIX);
|
||||
else
|
||||
{
|
||||
nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
|
||||
}
|
||||
fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.c_str());
|
||||
#ifdef RYZOM_SHARE_PREFIX
|
||||
fprintf(fp, "PreDataPath = { \"%s/data\" };\n", RYZOM_SHARE_PREFIX);
|
||||
#endif // RYZOM_SHARE_PREFIX
|
||||
fclose(fp);
|
||||
#else
|
||||
nlwarning("CFG::init: '%s' Not Found !!!", configFileName.c_str ());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("CFG::init: '%s' Not Found !!!", cfgFile.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// if the config file will be modified, it calls automatically the function setValuesOnFileChange()
|
||||
|
|
|
@ -727,12 +727,15 @@ void prelogInit()
|
|||
setReportEmailFunction ((void*)sendEmail);
|
||||
setDefaultEmailParams ("smtp.nevrax.com", "", "ryzombug@nevrax.com");
|
||||
|
||||
// create the save dir.
|
||||
// create the data dir.
|
||||
if (!CFile::isExists("data")) CFile::createDirectory("data");
|
||||
|
||||
// create the save dir.
|
||||
if (!CFile::isExists("save")) CFile::createDirectory("save");
|
||||
|
||||
// create the user dir.
|
||||
if (!CFile::isExists("user")) CFile::createDirectory("user");
|
||||
|
||||
#if !FINAL_VERSION
|
||||
// if we're not in final version then start the file access logger to keep track of the files that we read as we play
|
||||
//ICommand::execute("iFileAccessLogStart",*NLMISC::InfoLog);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#cmakedefine HAVE_DL_H 1
|
||||
#cmakedefine HAVE_EXECINFO_H 1
|
||||
#cmakedefine HAVE_ICONV 1
|
||||
|
@ -30,3 +33,10 @@
|
|||
#cmakedefine HAVE_STRTOULL 1
|
||||
#cmakedefine HAVE_STATVFS 1
|
||||
#cmakedefine HAVE_STAT64 1
|
||||
|
||||
#cmakedefine RYZOM_PREFIX "${RYZOM_PREFIX}"
|
||||
#cmakedefine RYZOM_BIN_PREFIX "${RYZOM_BIN_PREFIX}"
|
||||
#cmakedefine RYZOM_ETC_PREFIX "${RYZOM_ETC_PREFIX}"
|
||||
#cmakedefine RYZOM_SHARE_PREFIX "${RYZOM_SHARE_PREFIX}"
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
|
Loading…
Reference in a new issue