You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/11 01:38:53 UTC
[07/50] mesos git commit: Windows: Updated `os::exists()` to support
long paths.
Windows: Updated `os::exists()` to support long paths.
Review: https://reviews.apache.org/r/60299/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4f6719f6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4f6719f6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4f6719f6
Branch: refs/heads/master
Commit: 4f6719f6c422d002aa8edb61fa5489f64290a799
Parents: dd87bd4
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Jul 5 10:52:48 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:32 2017 -0700
----------------------------------------------------------------------
.../stout/include/stout/os/windows/exists.hpp | 23 ++++++++------------
1 file changed, 9 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4f6719f6/3rdparty/stout/include/stout/os/windows/exists.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/exists.hpp b/3rdparty/stout/include/stout/os/windows/exists.hpp
index 42b8a9d..7c8c85c 100644
--- a/3rdparty/stout/include/stout/os/windows/exists.hpp
+++ b/3rdparty/stout/include/stout/os/windows/exists.hpp
@@ -15,9 +15,10 @@
#include <string>
+#include <stout/error.hpp>
#include <stout/windows.hpp>
-#include <stout/os/realpath.hpp>
+#include <stout/internal/windows/longpath.hpp>
namespace os {
@@ -25,21 +26,15 @@ namespace os {
inline bool exists(const std::string& path)
{
- Result<std::string> absolutePath = os::realpath(path);
-
- if (!absolutePath.isSome()) {
- return false;
- }
-
- // NOTE: `GetFileAttributes` redirects to either `GetFileAttributesA`
- // (ASCII) or `GetFileAttributesW` (for `wchar`s). It returns
- // `INVALID_FILE_ATTRIBUTES` if the file could not be opened for any reason.
- // Checking for one of two 'not found' error codes (`ERROR_FILE_NOT_FOUND` or
- // `ERROR_PATH_NOT_FOUND`) is a reliable test for whether the file or
- // directory exists. See also [1] for more information on this technique.
+ // NOTE: `GetFileAttributes` returns `INVALID_FILE_ATTRIBUTES` if the file
+ // could not be opened for any reason. Checking for one of two 'not found'
+ // error codes (`ERROR_FILE_NOT_FOUND` or `ERROR_PATH_NOT_FOUND`) is a
+ // reliable test for whether the file or directory exists. See also [1] for
+ // more information on this technique.
//
// [1] http://blogs.msdn.com/b/oldnewthing/archive/2007/10/23/5612082.aspx
- DWORD attributes = GetFileAttributes(absolutePath.get().c_str());
+ const DWORD attributes = ::GetFileAttributesW(
+ ::internal::windows::longpath(path).data());
if (attributes == INVALID_FILE_ATTRIBUTES) {
DWORD error = GetLastError();