blob: 0db3a6c309a08ae4fa1189bf6439c63401f56034 (
plain) (
blame)
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
|
#include "fslock.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
namespace newsboat {
FsLock::FsLock()
: rs_object(fslock::bridged::create())
{
}
bool FsLock::try_lock(const Filepath& new_lock_filepath, pid_t& pid,
std::string& error_message)
{
std::int64_t p;
rust::String message;
const bool result = newsboat::fslock::bridged::try_lock(*rs_object,
new_lock_filepath, p, message);
// We use `libc::pid_t` on the rust side so we can guarantee this will fit
pid = static_cast<std::int64_t>(p);
error_message = std::string(message);
return result;
}
} // namespace newsboat
|