Skip to content

Commit cf6c9ea

Browse files
committed
change to duckdb filesystem
1 parent c920736 commit cf6c9ea

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/vortex_scan.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@
55
#include "duckdb/common/multi_file_reader.hpp"
66
#include "duckdb/function/table_function.hpp"
77
#include "duckdb/main/extension_util.hpp"
8+
#include "duckdb/common/file_system.hpp"
89
#include "vortex_extension.hpp"
910

10-
#if __has_include(<filesystem>)
11-
#include <filesystem>
12-
namespace fs = std::filesystem;
13-
#elif __has_include(<experimental/filesystem>)
14-
#include <experimental/filesystem>
15-
namespace fs = std::experimental::filesystem;
16-
#else
17-
#error "No filesystem support available"
18-
#endif
1911
#include <regex>
2012

2113
#include "vortex_common.hpp"
@@ -159,26 +151,22 @@ static void ExtractVortexSchema(const vx_dtype *file_dtype, vector<LogicalType>
159151
}
160152
}
161153

162-
const std::regex schema_prefix = std::regex("^[^/]*:\\/\\/.*$");
154+
const std::regex schema_prefix = std::regex("^[^/]*:\\/\\/.*$");
163155

164156
std::string EnsureFileProtocol(const std::string &path) {
165157
// Check if the path has a schema, if not prepend the file:// schema
166158
if (std::regex_match(path, schema_prefix)) {
167-
return path;
159+
return path;
168160
}
169161

170-
auto absolute_path = path;
171162
const std::string prefix = "file://";
172163

173-
fs::path p = absolute_path;
174-
if (!p.is_absolute()) {
175-
try {
176-
absolute_path = absolute(p).string();
177-
} catch (const std::exception &e) {
178-
throw InternalException(std::string("Error making path absolute: ") + e.what());
179-
}
164+
auto fs = FileSystem::CreateLocal();
165+
if (fs->IsPathAbsolute(path)) {
166+
return path;
180167
}
181168

169+
const auto absolute_path = fs->JoinPath(fs->GetWorkingDirectory(), path);
182170
return prefix + absolute_path;
183171
}
184172

0 commit comments

Comments
 (0)