MCPcopy Create free account
hub / github.com/clechasseur/pathcopycopy / GetHiddenDriveShareFilePath

Method GetHiddenDriveShareFilePath

PathCopyCopy/src/PluginUtils.cpp:318–337  ·  view source on GitHub ↗

Checks if the given file resides in a directory on a local drive. If it does, returns its corresponding network path using a hidden drive share. Ex: C:\Dir\File.txt -> \\thiscomputer\C$\Dir\File.txt @param p_rFilePath Local file path. Upon exit, will contain network path. @return true if the file was on a local drive and we fetched its network path.

Source from the content-addressed store, hash-verified

316 // @return true if the file was on a local drive and we fetched its network path.
317 //
318 bool PluginUtils::GetHiddenDriveShareFilePath(std::wstring& p_rFilePath)
319 {
320 // Try to perform the replacement in one shot. If it works, the path is converted.
321 bool converted = false;
322
323 try {
324 const std::wregex hiddenDriveShareRegex(HIDDEN_DRIVE_SHARES_REGEX, std::regex_constants::ECMAScript);
325 const std::wstring replaced = std::regex_replace(p_rFilePath, hiddenDriveShareRegex, HIDDEN_DRIVE_SHARES_FORMAT);
326 if (!replaced.empty()) {
327 std::wstringstream ss;
328 ss << L"\\\\" << GetLocalComputerName() << L"\\" << replaced;
329 p_rFilePath = ss.str();
330 converted = true;
331 }
332 } catch (const std::regex_error&) {
333 // Didn't work.
334 }
335
336 return converted;
337 }
338
339 //
340 // Replaces the hostname in the given UNC path with a

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected