diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
commit | bd6336c629841c6db3a6ca53a936d629d34db53b (patch) | |
tree | 3721ef997864108df175ce677a8a7d4342a6f1d2 /lib/dir_exist_async.h | |
parent | 4.0 (diff) | |
download | FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2 FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip |
4.1
Diffstat (limited to 'lib/dir_exist_async.h')
-rw-r--r-- | lib/dir_exist_async.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/dir_exist_async.h b/lib/dir_exist_async.h new file mode 100644 index 00000000..72741ee2 --- /dev/null +++ b/lib/dir_exist_async.h @@ -0,0 +1,42 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef DIR_EXIST_HEADER_08173281673432158067342132467183267 +#define DIR_EXIST_HEADER_08173281673432158067342132467183267 + +#include <zen/thread.h> +#include <zen/file_handling.h> +#include "status_handler.h" +#include <zen/file_error.h> +#include "resolve_path.h" + +//dir existence checking may hang for non-existent network drives => run asynchronously and update UI! +namespace +{ +bool dirExistsUpdating(const Zstring& dirname, bool allowUserInteraction, ProcessCallback& procCallback) +{ + using namespace zen; + + std::wstring statusText = _("Searching for directory %x..."); + replace(statusText, L"%x", std::wstring(L"\"") + dirname + L"\"", false); + procCallback.reportStatus(statusText); + + auto ft = async([=]() -> bool + { +#ifdef FFS_WIN + //1. login to network share, if necessary + loginNetworkShare(dirname, allowUserInteraction); +#endif + //2. check dir existence + return zen::dirExists(dirname); + }); + while (!ft.timed_wait(boost::posix_time::milliseconds(UI_UPDATE_INTERVAL))) + procCallback.requestUiRefresh(); //may throw! + return ft.get(); +} +} + +#endif //DIR_EXIST_HEADER_08173281673432158067342132467183267 |