summaryrefslogtreecommitdiff
path: root/library/dir_exist_async.h
blob: 60fa4582f7e9cb34cb957f13f2bf904136022a69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// **************************************************************************
// * 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 "../shared/check_exist.h"
#include "status_handler.h"
#include "../shared/file_error.h"
#include "../shared/i18n.h"

//dir existence checking may hang for non-existent network drives => run asynchronously and update UI!
namespace
{
using namespace zen; //restricted to unnamed namespace!

bool dirExistsUpdating(const Zstring& dirname, ProcessCallback& procCallback)
{
    using namespace util;

    //do NOT include info messages here! this method is used by synchronization also, so avoid flooding!

    auto ft = dirExistsAsync(dirname);
    while (!ft.timed_wait(boost::posix_time::milliseconds(UI_UPDATE_INTERVAL)))
        procCallback.requestUiRefresh(); //may throw!
    return ft.get();
}
}

#endif //DIR_EXIST_HEADER_08173281673432158067342132467183267
bgstack15