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