MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / getQueryFromFile

Function getQueryFromFile

src/binder/bind/bind_import_database.cpp:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace binder {
17
18static std::string getQueryFromFile(VirtualFileSystem* vfs, const std::string& boundFilePath,
19 const std::string& fileName, main::ClientContext* context) {
20 auto filePath = vfs->joinPath(boundFilePath, fileName);
21 if (!vfs->fileOrPathExists(filePath, context)) {
22 if (fileName == PortDBConstants::COPY_FILE_NAME) {
23 return "";
24 }
25 if (fileName == PortDBConstants::INDEX_FILE_NAME) {
26 return "";
27 }
28 throw BinderException(std::format("File {} does not exist.", filePath));
29 }
30 auto fileInfo = vfs->openFile(filePath, FileOpenFlags(FileFlags::READ_ONLY
31#ifdef _WIN32
32 | FileFlags::BINARY
33#endif
34 ));
35 auto fsize = fileInfo->getFileSize();
36 auto buffer = std::make_unique<char[]>(fsize);
37 fileInfo->readFile(buffer.get(), fsize);
38 return std::string(buffer.get(), fsize);
39}
40
41static std::string getColumnNamesToCopy(const CopyFrom& copyFrom) {
42 std::string columns = "";

Callers 1

Calls 7

FileOpenFlagsClass · 0.85
joinPathMethod · 0.45
fileOrPathExistsMethod · 0.45
openFileMethod · 0.45
getFileSizeMethod · 0.45
readFileMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected