MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/fstream/main.cpp:20–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20int 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}

Callers

nothing calls this directly

Calls 9

test_stdioFunction · 0.85
acl_last_serrorFunction · 0.85
file_handleMethod · 0.80
getsMethod · 0.80
open_readMethod · 0.45
c_strMethod · 0.45
openMethod · 0.45
lockMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…