From eb5d3e5df99de2c3d8da2e8bc7b12ed427465dba Mon Sep 17 00:00:00 2001 From: B Stack Date: Sun, 9 Sep 2018 18:53:23 -0400 Subject: pull in latest 10.4 from upstream --- zen/file_access.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'zen/file_access.cpp') diff --git a/zen/file_access.cpp b/zen/file_access.cpp index 9c351e25..a81fdae0 100755 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -30,9 +30,9 @@ using namespace zen; -Opt zen::parsePathComponents(const Zstring& itemPath) +std::optional zen::parsePathComponents(const Zstring& itemPath) { - auto doParse = [&](int sepCountVolumeRoot, bool rootWithSep) -> Opt + auto doParse = [&](int sepCountVolumeRoot, bool rootWithSep) -> std::optional { const Zstring itemPathFmt = appendSeparator(itemPath); //simplify analysis of root without separator, e.g. \\server-name\share int sepCount = 0; @@ -47,7 +47,7 @@ Opt zen::parsePathComponents(const Zstring& itemPath) return PathComponents({ rootPath, relPath }); } - return NoValue(); + return {}; }; if (startsWith(itemPath, "/")) @@ -72,17 +72,17 @@ Opt zen::parsePathComponents(const Zstring& itemPath) } //we do NOT support relative paths! - return NoValue(); + return {}; } -Opt zen::getParentFolderPath(const Zstring& itemPath) +std::optional zen::getParentFolderPath(const Zstring& itemPath) { - if (const Opt comp = parsePathComponents(itemPath)) + if (const std::optional comp = parsePathComponents(itemPath)) { if (comp->relPath.empty()) - return NoValue(); + return {}; const Zstring parentRelPath = beforeLast(comp->relPath, FILE_NAME_SEPARATOR, IF_MISSING_RETURN_NONE); if (parentRelPath.empty()) @@ -90,7 +90,7 @@ Opt zen::getParentFolderPath(const Zstring& itemPath) return appendSeparator(comp->rootPath) + parentRelPath; } assert(false); - return NoValue(); + return {}; } @@ -110,7 +110,7 @@ ItemType zen::getItemType(const Zstring& itemPath) //throw FileError PathStatus zen::getPathStatus(const Zstring& itemPath) //throw FileError { - const Opt parentPath = getParentFolderPath(itemPath); + const std::optional parentPath = getParentFolderPath(itemPath); try { return { getItemType(itemPath), itemPath, {} }; //throw FileError @@ -145,12 +145,12 @@ PathStatus zen::getPathStatus(const Zstring& itemPath) //throw FileError } -Opt zen::getItemTypeIfExists(const Zstring& itemPath) //throw FileError +std::optional zen::getItemTypeIfExists(const Zstring& itemPath) //throw FileError { const PathStatus ps = getPathStatus(itemPath); //throw FileError if (ps.relPath.empty()) return ps.existingType; - return NoValue(); + return {}; } @@ -672,7 +672,7 @@ FileCopyResult copyFileOsSpecific(const Zstring& sourceFile, //throw FileError, //close output file handle before setting file time; also good place to catch errors when closing stream! fileOut.finalize(); //throw FileError, (X) essentially a close() since buffers were already flushed - Opt errorModTime; + std::optional errorModTime; try { //we cannot set the target file times (::futimes) while the file descriptor is still open after a write operation: -- cgit