Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
write_lock.cpp
Go to the documentation of this file.
3
4#include <iostream>
5
6namespace joedb
7{
8 /////////////////////////////////////////////////////////////////
9 static int main(int argc, char **argv)
10 /////////////////////////////////////////////////////////////////
11 {
12 if (argc < 2)
13 {
14 std::cerr << "usage: " << argv[0] << " <file_name>\n";
15 return 1;
16 }
17
18 const char * const file_name = argv[1];
19
20 std::cout << "Locking " << file_name << "...";
21 std::cout.flush();
22
23 File lock(file_name, Open_Mode::write_lock);
24
25 std::cout << "\nLocked. Enter to stop.";
26 std::cout.flush();
27 std::cin.get();
28
29 return 0;
30 }
31}
32
33//////////////////////////////////////////////////////////////////
34int main(int argc, char **argv)
35//////////////////////////////////////////////////////////////////
36{
37 joedb::main_exception_catcher(joedb::main, argc, argv);
38}
int main()
@ write_lock
like write_existing_or_create_new, but waits instead of failing if already locked
int main_exception_catcher(int(*main)(int, char **), int argc, char **argv)
Catch exception from main.
Definition Blob.h:7
JOEDB_FILE File
Definition File.h:25