| 18 | } |
| 19 | |
| 20 | int main(void) |
| 21 | { |
| 22 | test_stdio(); |
| 23 | |
| 24 | acl::string path("test.eml"); |
| 25 | |
| 26 | acl::ifstream fp; |
| 27 | |
| 28 | if (fp.open_read(path) == false) { |
| 29 | //if (fp.open(path.c_str(), O_RDWR, 0600) == false) { |
| 30 | printf("open %s error(%s)\n", path.c_str(), acl_last_serror()); |
| 31 | getchar(); |
| 32 | return (-1); |
| 33 | } |
| 34 | |
| 35 | acl::locker locker; |
| 36 | if (locker.open(fp.file_handle()) == false) { |
| 37 | printf("open %s's lock error\n", path.c_str()); |
| 38 | getchar(); |
| 39 | return (-1); |
| 40 | } |
| 41 | if (locker.lock() == true) |
| 42 | printf("first lock %s ok\n", path.c_str()); |
| 43 | else |
| 44 | printf("first lock %s error(%s)\n", path.c_str(), acl_last_serror()); |
| 45 | |
| 46 | #ifndef WIN32 |
| 47 | if (locker.lock() == true) |
| 48 | printf("second lock %s ok\n", path.c_str()); |
| 49 | else |
| 50 | printf("second lock %s error(%s)\n", path.c_str(), acl_last_serror()); |
| 51 | #endif |
| 52 | |
| 53 | acl::string buf; |
| 54 | while (1) { |
| 55 | if (fp.gets(buf, false) == false) |
| 56 | break; |
| 57 | printf("%s", buf.c_str()); |
| 58 | } |
| 59 | fp.close(); |
| 60 | |
| 61 | printf("enter any key to exit\r\n"); |
| 62 | getchar(); |
| 63 | |
| 64 | return (0); |
| 65 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…