MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / getFileName

Method getFileName

CesiumUtility/src/Uri.cpp:150–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150std::string_view Uri::getFileName() const {
151 if (!this->isValid()) {
152 return {};
153 }
154
155 uint32_t pathLength = this->_url->get_pathname_length();
156 // If the pathname is empty or just "/", there's no filename.
157 if (pathLength <= 1) {
158 return {};
159 }
160
161 const std::string_view path = this->_url->get_pathname();
162 const int32_t end = (int32_t)(pathLength - 1);
163 for (int32_t i = end; i >= 0; i--) {
164 if (path[(size_t)i] != '/') {
165 continue;
166 }
167
168 // Last char of pathname is '/', so no filename
169 if (i == end) {
170 return {};
171 }
172
173 return path.substr((size_t)(i + 1), (size_t)(end - i));
174 }
175
176 // If we've gotten this far, the whole pathname is the filename
177 return path;
178}
179
180std::string_view Uri::getStem() const {
181 const std::string_view filename = this->getFileName();

Callers 3

getStemMethod · 0.95
getExtensionMethod · 0.95
TestUri.cppFile · 0.80

Calls 1

isValidMethod · 0.95

Tested by

no test coverage detected