Skip to content

Commit

Permalink
initial support for FUSE
Browse files Browse the repository at this point in the history
  • Loading branch information
Talv committed Jul 31, 2019
1 parent d43b155 commit 704e7d0
Show file tree
Hide file tree
Showing 10 changed files with 536 additions and 12 deletions.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 2.6)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${STORMEXTRACT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${STORMEXTRACT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${STORMEXTRACT_BINARY_DIR}/bin")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

set(default_build_type "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand All @@ -15,10 +16,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# compile flags
set(CMAKE_CXX_FLAGS "-std=c++11")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
set(FUSE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=27")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FUSE_REQUIRED_FLAGS}")

# modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules")

if (NOT EXISTS "${STORMEXTRACT_SOURCE_DIR}/CascLib/CMakeLists.txt")
message(FATAL_ERROR
Expand All @@ -38,6 +45,14 @@ endif()
add_subdirectory(CascLib)
add_subdirectory(plog)

# FUSE
find_package(FUSE REQUIRED)
if(NOT FUSE_FOUND)
message(FATAL_ERROR "Failed to find fuse")
else()
include_directories(${FUSE_INCLUDE_DIR})
endif()

include_directories("${STORMEXTRACT_SOURCE_DIR}/include/"
"${STORMEXTRACT_SOURCE_DIR}/CascLib/src/"
"${STORMEXTRACT_SOURCE_DIR}/cxxopts/include/"
Expand All @@ -47,12 +62,15 @@ include_directories("${STORMEXTRACT_SOURCE_DIR}/include/"
set(SRC_FILES
src/util.cc
src/storage.cc
src/cascfuse.cc
src/stormex.cc
)

add_executable(stormex ${SRC_FILES})

target_link_libraries(stormex plog)
target_link_libraries(stormex
${FUSE_LIBRARIES}
)

if(WIN32)
target_link_libraries(stormex casc_static)
Expand Down
35 changes: 35 additions & 0 deletions CMakeModules/FindFUSE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Find the FUSE includes and library
#
# FUSE_INCLUDE_DIR - where to find fuse.h, etc.
# FUSE_LIBRARIES - List of libraries when using FUSE.
# FUSE_FOUND - True if FUSE lib is found.

# check if already in cache, be silent
IF (FUSE_INCLUDE_DIR)
SET (FUSE_FIND_QUIETLY TRUE)
ENDIF (FUSE_INCLUDE_DIR)

# find includes
FIND_PATH (FUSE_INCLUDE_DIR fuse.h
/usr/local/include/osxfuse
/usr/local/include
/usr/include
)

# find lib
if (APPLE)
SET(FUSE_NAMES libosxfuse.dylib fuse)
else (APPLE)
SET(FUSE_NAMES fuse)
endif (APPLE)
FIND_LIBRARY(FUSE_LIBRARIES
NAMES ${FUSE_NAMES}
PATHS /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args ("FUSE" DEFAULT_MSG
FUSE_INCLUDE_DIR FUSE_LIBRARIES)

mark_as_advanced (FUSE_INCLUDE_DIR FUSE_LIBRARIES)

5 changes: 5 additions & 0 deletions include/cascfuse.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "storage.hpp"

int cascf_mount(const std::string& mountPoint, HANDLE hStorage);
2 changes: 1 addition & 1 deletion include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "mplog/ColorConsoleAppenderStderr.h"
// #include "plog/Formatters/FuncMessageFormatter.h"

static const std::string stormexVersion = "2.0.1";
static const std::string stormexVersion = "2.1.0";

static plog::ColorConsoleAppenderStdErr<plog::TxtFormatter> consoleAppender;
// static plog::ColorConsoleAppender<plog::FuncMessageFormatter> consoleAppender;
Expand Down
4 changes: 3 additions & 1 deletion include/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class StorageExplorer {
HANDLE m_hStorage = nullptr;

public:
const HANDLE& getHandle() { return m_hStorage; }
HANDLE getHandle() { return m_hStorage; }

~StorageExplorer();

/**
* @brief Open CASC
Expand Down
5 changes: 4 additions & 1 deletion include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ int ensureDirExists(std::string strDestName);
std::string formatFileSize(size_t size);

/// Try to find in the Haystack the Needle - ignore case
bool findStringIC(const std::string& strHaystack, const std::string& strNeedle);
bool stringFindIC(const std::string& strHaystack, const std::string& strNeedle);
bool stringEqualIC(const std::string& str1, const std::string& str2);
void stringToLower(std::string& str);
std::string stringToLowerCopy(std::string str);

#endif // __UTIL_HPP__
Loading

0 comments on commit 704e7d0

Please sign in to comment.