80051 : LazyMultiFileList(FileOpener::TryGetClientContext(opener)), fs(fs), path(fs.
ExpandPath(path_p, opener)),
80052 opener(opener) {
80053 if (path.empty()) {
80054 finished = true;
80055 return;
80056 }
80057
80058 idx_t last_pos = 0;
80059 for (idx_t i = 0; i < path.size(); i++) {
80060 if (path[i] == '\\' || path[i] == '/') {
80061 if (i == last_pos) {
80062
80063 last_pos = i + 1;
80064 continue;
80065 }
80066 if (splits.empty()) {
80067 splits.emplace_back(fs, path.substr(0, i));
80068 } else {
80069 splits.emplace_back(fs, path.substr(last_pos, i - last_pos));
80070 }
80071 last_pos = i + 1;
80072 }
80073 }
80074 splits.emplace_back(fs, path.substr(last_pos, path.size() - last_pos));
80075
80076 absolute_path = false;
80078
80079 absolute_path = true;
80081 ":")) {
80082
80083 absolute_path = true;
80084 } else if (splits[0].path == "~") {
80085
80087 if (!home_directory.empty()) {
80088 absolute_path = true;
80089 splits[0].path = home_directory;
80090 D_ASSERT(path[0] == '~');
80092 expanded_files = fs.FetchFileWithoutGlob(home_directory + path.substr(1), opener, absolute_path);
80093 finished = true;
80094 return;
80095 }
80096 }
80097 }
80098
80100
80101 expanded_files = fs.FetchFileWithoutGlob(path, opener, absolute_path);
80102 finished = true;
80103 return;
80104 }
80105 if (absolute_path) {
80106
80107
80108 if (splits.size() > 1) {
80109 expand_directories.emplace(splits[0].path, 1);
80110 }
80111 } else {
80112
80113 Value value;
80114 if (opener && opener->TryGetCurrentSetting("file_search_path", value)) {
80115 auto search_paths_str = value.ToString();
80117 for (const auto &search_path : search_paths) {
80118 expand_directories.emplace(search_path, 0);
80119 }
80120 }
80121 if (expand_directories.empty()) {
80122 expand_directories.emplace(".", 0, true);
80123 }
80124 }
80125
80126 if (HasMultipleCrawl(splits)) {
80127 throw IOException("Cannot use multiple \'**\' in one path");
80128 }
80129}
static DUCKDB_API string GetHomeDirectory(optional_ptr< FileOpener > opener)
Gets the users home directory.
Definition duckdb.cpp:73850
static DUCKDB_API string ExpandPath(const string &path, optional_ptr< FileOpener > opener)
Expands a given path, including e.g. expanding the home directory of the user.
Definition duckdb.cpp:73909
static DUCKDB_API bool HasGlob(const string &str)
Whether there is a glob in the string.
Definition duckdb.cpp:74130
vector< OpenFileInfo > expanded_files
The expanded files.
Definition duckdb.cpp:53855
bool IsPathAbsolute(const string &path) override
Checks if path is is an absolute path.
Definition duckdb.cpp:79196
static DUCKDB_API bool Contains(const string &haystack, const string &needle)
Returns true if the needle string exists in the haystack.
static DUCKDB_API vector< string > Split(const string &str, char delimiter)
Split the input string based on newline char.