MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / openedPathWithinRoots

Function openedPathWithinRoots

app/src/AI/FileSandbox.cpp:181–197  ·  view source on GitHub ↗

* @brief Re-canonicalizes an opened path and confirms it still resolves within a root. */

Source from the content-addressed store, hash-verified

179 * @brief Re-canonicalizes an opened path and confirms it still resolves within a root.
180 */
181static bool openedPathWithinRoots(const QString& openedPath, const QStringList& roots)
182{
183 const QFileInfo info(openedPath);
184 const auto canonical = info.canonicalFilePath();
185 if (canonical.isEmpty())
186 return false;
187
188 for (const auto& root : roots) {
189 if (root.isEmpty())
190 continue;
191
192 if (canonical == root || canonical.startsWith(root + QLatin1Char('/')))
193 return true;
194 }
195
196 return false;
197}
198
199/**
200 * @brief Resolves an input path for reading against the workspace + dropped roots.

Callers 1

readMethod · 0.85

Calls 1

isEmptyMethod · 0.80

Tested by

no test coverage detected