Skip to content

Commit

Permalink
Use cross-platform glob library to better support globbing on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed May 23, 2023
1 parent 91204de commit 7e0e821
Show file tree
Hide file tree
Showing 6 changed files with 458 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ add_library(kuzu_common
utils.cpp
string_utils.cpp)

target_link_libraries(kuzu_common Glob)

set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common>
PARENT_SCOPE)
8 changes: 3 additions & 5 deletions src/common/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "common/exception.h"
#include "common/string_utils.h"
#include <glob/glob.hpp>

namespace kuzu {
namespace common {
Expand Down Expand Up @@ -118,12 +119,9 @@ void FileUtils::removeFileIfExists(const std::string& path) {

std::vector<std::string> FileUtils::globFilePath(const std::string& path) {
std::vector<std::string> result;
glob_t globResult;
glob(path.c_str(), GLOB_TILDE, nullptr, &globResult);
for (auto i = 0u; i < globResult.gl_pathc; ++i) {
result.emplace_back(globResult.gl_pathv[i]);
for (auto &resultPath: glob::glob(path)) {
result.emplace_back(resultPath.string());
}
globfree(&globResult);
return result;
}

Expand Down
1 change: 0 additions & 1 deletion src/include/common/file_utils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <fcntl.h>
#include <glob.h>
#include <sys/stat.h>
#include <unistd.h>

Expand Down
1 change: 1 addition & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ add_subdirectory(antlr4_cypher)
add_subdirectory(utf8proc)
add_subdirectory(pybind11)
add_subdirectory(re2)
add_subdirectory(glob)
3 changes: 3 additions & 0 deletions third_party/glob/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_library(Glob INTERFACE glob/glob.hpp)

target_include_directories(Glob INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
Loading

0 comments on commit 7e0e821

Please sign in to comment.