mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-01 03:17:37 +08:00
550b1095de
This reverts commit dff6771da7
.
34 lines
551 B
C++
34 lines
551 B
C++
#include "acl_cpp/stdlib/locker.hpp"
|
|
#include "acl_cpp/stream/fstream.hpp"
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
|
|
int main(void)
|
|
{
|
|
acl::fstream fp;
|
|
|
|
if (fp.open("test.lock", O_RDWR, 0600) == false) {
|
|
printf("open file error\n");
|
|
getchar();
|
|
return (1);
|
|
}
|
|
|
|
acl::locker locker;
|
|
|
|
if (locker.open(fp.file_handle()) == false) {
|
|
printf("open lock error\n");
|
|
getchar();
|
|
return (1);
|
|
}
|
|
if (locker.lock() == true) {
|
|
printf("lock ok\n");
|
|
} else {
|
|
printf("lock error\n");
|
|
}
|
|
|
|
printf("enter any key to exit\n");
|
|
getchar();
|
|
return (0);
|
|
}
|
|
|