boost::filesystem cross-platform config file check

* introduces the use of the Boost.System and Boost.Filesystem libraries,
  which must be built and linked to rather than just compiled into
  OpenMW. May be a pain in the neck to get working on other platforms,
  but once it works, we have all of Boost to work with.
actorid
Ardekantur 15 years ago
parent 4d8040f96c
commit ad1e9e7078

@ -23,10 +23,11 @@ endif (WIN32)
# Dependencies
find_package(OGRE REQUIRED)
find_package(Boost REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem)
include_directories("." ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
# Main executable
add_executable(openmw ${BSA} ${TOOLS} ${OGRE} ${GAME})
target_link_libraries(openmw ${OGRE_LIBRARIES})
target_link_libraries(openmw ${Boost_LIBRARIES})

@ -16,8 +16,8 @@ Getting OpenMW Working
1. Clone this repository.
2. Install `bjam` through MacPorts.
3. Download [boost][] 1.43 and install it with the following command:
$ mkdir build && sudo bjam --build-dir=build --layout=versioned --toolset=darwin --architecture=combined --address-model=32 --link=shared,static install
$ mkdir build && sudo bjam --build-dir=build --layout=versioned --toolset=darwin architecture=i386 address-model=32 --link=shared,static install
4. Download [Ogre][] 1.7.1 and build and Xcode project with CMake:
@ -28,10 +28,10 @@ Getting OpenMW Working
6. Generate the Makefile for OpenMW as follows:
$ mkdir build && cd build && BOOST_INCLUDEDIR=/usr/local/include/boost-1_43 BOOST_LIBRARYDIR=/usr/local/lib CMAKE_OSX_ARCHITECTURES=i386 cmake ..
7. Move your Morrowind `Data Files` directory into `build`, renamed as `data`.
[boost]: http://www.boost.org
[Ogre]: http://www.ogre3d.org
[official website]: http://openmw.com
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/

@ -1,44 +1,8 @@
#include "fileops.hpp"
// Windows-specific implementation (NOT TESTED)
#ifdef _WIN32
#include <windows.h>
bool isFile(const char *name)
{
unsigned int stat = GetFileAttributes(name);
return (stat != 0xFFFFFFFF &&
(stat & FILE_ATTRIBUTE_DIRECTORY) == 0);
}
#elif __linux__ // Linux implementations
#include <sys/stat.h>
#include <unistd.h>
#include <boost/filesystem.hpp>
bool isFile(const char *name)
{
// Does the file exist?
if(access(name,0) != 0)
return false;
struct stat st;
if(stat(name, &st)) return false;
return S_ISREG(st.st_mode);
}
#elif __APPLE__ // Darwin implementations
#include <sys/stat.h>
#include <unistd.h>
bool isFile(const char *name)
{
// Does the file exist?
if(access(name,0) != 0)
return false;
struct stat st;
if(stat(name, &st)) return false;
return S_ISREG(st.st_mode);
boost::filesystem::path cfg_file_path(name);
return boost::filesystem::exists(cfg_file_path);
}
#endif

Loading…
Cancel
Save