MCPcopy Create free account
hub / github.com/duckdb/duckdb / GetFileName

Method GetFileName

src/common/string_util.cpp:864–886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864string StringUtil::GetFileName(const string &file_path) {
865 idx_t pos = file_path.find_last_of("/\\");
866 if (pos == string::npos) {
867 return file_path;
868 }
869 auto end = file_path.size() - 1;
870
871 // If the rest of the string is just slashes or dots, trim them
872 if (file_path.find_first_not_of("/\\.", pos) == string::npos) {
873 // Trim the trailing slashes and dots
874 while (end > 0 && (file_path[end] == '/' || file_path[end] == '.' || file_path[end] == '\\')) {
875 end--;
876 }
877
878 // Now find the next slash
879 pos = file_path.find_last_of("/\\", end);
880 if (pos == string::npos) {
881 return file_path.substr(0, end + 1);
882 }
883 }
884
885 return file_path.substr(pos + 1, end - pos);
886}
887
888string StringUtil::GetFileExtension(const string &file_name) {
889 auto name = GetFileName(file_name);

Callers 15

FinalizeBindMethod · 0.80
FinalizeChunkMethod · 0.80
PruneReadersMethod · 0.80
MultiFileInitGlobalMethod · 0.80
CreateReaderMethod · 0.80
FillScanErrorTableFunction · 0.80
LogFlushingRowGroupMethod · 0.80
InitializeReadMethod · 0.80
PrepareReadMethod · 0.80
PreparePageV2Method · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected