Skip to content

Commit 2aeb644

Browse files
update from nextgeniuspro (nextgeniuspro#7)
* Add CloseFile override for ZipFileSystem add gitignore for out (default for CPM/FetchContent/Visual Studio in-source builds) * Optional build of examples added library alias target for conformity Modified examples for in-lib build * using binary mode for opening NativeFile * Update miniz-cpp submodule url * Update readme --------- Co-authored-by: Yev <evg1985@gmail.com>
1 parent 9fdf5ae commit 2aeb644

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
/build
3131
/examples/build
3232
.vscode/settings.json
33+
34+
/out/**

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "vendor/miniz-cpp"]
22
path = vendor/miniz-cpp
3-
url = https://github.com/tfussell/miniz-cpp.git
3+
url = https://github.com/nextgeniuspro/miniz-cpp.git

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
# Project name and version
44
project(vfspp VERSION 1.0 LANGUAGES CXX)
5-
5+
option(BUILD_EXAMPLES "Build examples" OFF)
66
# Add the miniz-cpp library
77
add_subdirectory(vendor/miniz-cpp EXCLUDE_FROM_ALL)
88

@@ -13,6 +13,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1313

1414
# Add the include directory as a target
1515
add_library(vfspp INTERFACE)
16+
add_library(vfspp::vfspp ALIAS vfspp)
1617

1718
target_include_directories(vfspp
1819
INTERFACE
@@ -21,4 +22,8 @@ target_include_directories(vfspp
2122
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/miniz-cpp>
2223
)
2324

24-
target_compile_features(vfspp INTERFACE cxx_std_17)
25+
target_compile_features(vfspp INTERFACE cxx_std_17)
26+
27+
if (BUILD_EXAMPLES)
28+
add_subdirectory(examples)
29+
endif()

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ See examples/CMakeLists.txt for example of usage
142142

143143
## How To Build Example #
144144

145-
- Navigate to 'examples' directory
145+
- Run cmake to generate project windows project files
146146
```bash
147-
cd examples
148-
```
149-
- Run cmake to generate project
147+
cmake -B ./build -G "Visual Studio 17 2022" . -DBUILD_EXAMPLES=1
148+
```
149+
or to generate Xcode project files
150150
```bash
151-
cmake -B ./build -G "Visual Studio 17 2022" .
151+
cmake -B ./build -G "Xcode" . -DBUILD_EXAMPLES=1
152152
```
153+
154+
- Open generated project files and build the target `vfsppexample`

examples/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ cmake_minimum_required(VERSION 3.10)
22

33
project(vfsppexample)
44

5-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. vfspp_build)
5+
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. vfspp_build)
66

77
add_executable(vfsppexample example.cpp)
88

99
add_compile_definitions(VFSPP_ENABLE_MULTITHREADING)
1010

11-
target_link_libraries(vfsppexample PRIVATE vfspp)
11+
target_link_libraries(vfsppexample PRIVATE vfspp::vfspp)
1212
target_compile_features(vfsppexample PRIVATE cxx_std_17)
1313

1414
# Specify the output directory
15+
set(COPY_SOURCE ${CMAKE_SOURCE_DIR}/examples/test-data)
1516
set(COPY_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test-data)
1617

1718
# Add a post-build step to copy the whole directory
1819
add_custom_command(TARGET vfsppexample POST_BUILD
19-
COMMAND ${CMAKE_COMMAND} -E copy_directory
20-
${CMAKE_SOURCE_DIR}/test-data
21-
${COPY_DESTINATION}
20+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COPY_SOURCE} ${COPY_DESTINATION}
2221
)

include/vfspp/NativeFile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class NativeFile final : public IFile
246246
m_Mode = mode;
247247
m_IsReadOnly = true;
248248

249-
std::ios_base::openmode open_mode = (std::ios_base::openmode)0x00;
249+
std::ios_base::openmode open_mode = std::ios_base::binary;
250250
if ((mode & FileMode::Read) == FileMode::Read) {
251251
open_mode |= std::fstream::in;
252252
}

include/vfspp/ZipFileSystem.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ class ZipFileSystem final : public IFileSystem
144144
{
145145
return false;
146146
}
147-
147+
/*
148+
* Close file
149+
*/
150+
virtual void CloseFile(IFilePtr file) override
151+
{
152+
//NO-OP
153+
}
148154
/*
149155
* Check if file exists on filesystem
150156
*/

0 commit comments

Comments
 (0)