summaryrefslogtreecommitdiff
path: root/zen/file_access.cpp
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2018-09-09 18:53:23 -0400
committerB Stack <bgstack15@gmail.com>2018-09-09 18:53:23 -0400
commiteb5d3e5df99de2c3d8da2e8bc7b12ed427465dba (patch)
tree0f0441755ff0e6d65e12222d4502c648bffd6a7c /zen/file_access.cpp
parent10.3 (diff)
downloadFreeFileSync-eb5d3e5df99de2c3d8da2e8bc7b12ed427465dba.tar.gz
FreeFileSync-eb5d3e5df99de2c3d8da2e8bc7b12ed427465dba.tar.bz2
FreeFileSync-eb5d3e5df99de2c3d8da2e8bc7b12ed427465dba.zip
pull in latest 10.4 from upstream
Diffstat (limited to 'zen/file_access.cpp')
-rwxr-xr-xzen/file_access.cpp24
1 files changed, 12 insertions, 12 deletions
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<PathComponents> zen::parsePathComponents(const Zstring& itemPath)
+std::optional<PathComponents> zen::parsePathComponents(const Zstring& itemPath)
{
- auto doParse = [&](int sepCountVolumeRoot, bool rootWithSep) -> Opt<PathComponents>
+ auto doParse = [&](int sepCountVolumeRoot, bool rootWithSep) -> std::optional<PathComponents>
{
const Zstring itemPathFmt = appendSeparator(itemPath); //simplify analysis of root without separator, e.g. \\server-name\share
int sepCount = 0;
@@ -47,7 +47,7 @@ Opt<PathComponents> zen::parsePathComponents(const Zstring& itemPath)
return PathComponents({ rootPath, relPath });
}
- return NoValue();
+ return {};
};
if (startsWith(itemPath, "/"))
@@ -72,17 +72,17 @@ Opt<PathComponents> zen::parsePathComponents(const Zstring& itemPath)
}
//we do NOT support relative paths!
- return NoValue();
+ return {};
}
-Opt<Zstring> zen::getParentFolderPath(const Zstring& itemPath)
+std::optional<Zstring> zen::getParentFolderPath(const Zstring& itemPath)
{
- if (const Opt<PathComponents> comp = parsePathComponents(itemPath))
+ if (const std::optional<PathComponents> 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<Zstring> 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<Zstring> parentPath = getParentFolderPath(itemPath);
+ const std::optional<Zstring> parentPath = getParentFolderPath(itemPath);
try
{
return { getItemType(itemPath), itemPath, {} }; //throw FileError
@@ -145,12 +145,12 @@ PathStatus zen::getPathStatus(const Zstring& itemPath) //throw FileError
}
-Opt<ItemType> zen::getItemTypeIfExists(const Zstring& itemPath) //throw FileError
+std::optional<ItemType> 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<FileError> errorModTime;
+ std::optional<FileError> errorModTime;
try
{
//we cannot set the target file times (::futimes) while the file descriptor is still open after a write operation:
bgstack15