blob: e94e22ac8bc63cf6e4fa00cac6ae2e5ec4707de4 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceUtil/FileUtil.h>
#include <IceUtil/Exception.h>
#include <TestCommon.h>
using namespace IceUtil;
using namespace std;
int
main(int, char**)
{
{
IceUtilInternal::FileLockPtr lock;
try
{
lock = new IceUtilInternal::FileLock("file.lock");
test(true);
}
catch(const exception& ex)
{
cerr << "exception:\n" << ex.what() << endl;
test(false);
}
catch(...)
{
test(false);
}
cout << "File lock acquired.\n"
<< "Enter some input and press enter, to release the lock and terminate the program." << endl;
//
// Block the test waiting for IO, so the file lock is preserved.
//
string dummy;
cin >> dummy;
}
cout << "File lock released." << endl;
return EXIT_SUCCESS;
}
|