| 74 | } |
| 75 | |
| 76 | static int test_vstream(void) |
| 77 | { |
| 78 | const char *filename = "test.txt"; |
| 79 | ACL_VSTREAM *fp = acl_vstream_fopen(filename, O_RDWR | O_CREAT, 0644, 1024); |
| 80 | struct acl_stat sbuf; |
| 81 | char buf[256]; |
| 82 | struct tm *local_time; |
| 83 | |
| 84 | acl_lib_init(); |
| 85 | |
| 86 | if (fp == NULL) { |
| 87 | printf("open file(%s) error(%s)\r\n", filename, acl_last_serror()); |
| 88 | end(); |
| 89 | return (-1); |
| 90 | } |
| 91 | |
| 92 | if (acl_vstream_fstat(fp, &sbuf) < 0) { |
| 93 | acl_vstream_close(fp); |
| 94 | printf("fstat file(%s) error(%s)\r\n", filename, acl_last_serror()); |
| 95 | end(); |
| 96 | return (-1); |
| 97 | } |
| 98 | |
| 99 | printf("file(%s) stat:\r\n", filename); |
| 100 | |
| 101 | printf("size=%d\r\n", (int) sbuf.st_size); |
| 102 | |
| 103 | local_time = localtime(&sbuf.st_mtime); |
| 104 | if (local_time) { |
| 105 | strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", local_time); |
| 106 | printf("��ʱ�䣬mtime=%s\r\n", buf); |
| 107 | } else { |
| 108 | printf("mtime: error(%s)\r\n", acl_last_serror()); |
| 109 | } |
| 110 | |
| 111 | local_time = localtime(&sbuf.st_ctime); |
| 112 | if (local_time) { |
| 113 | strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", local_time); |
| 114 | printf("����ʱ�䣬ctime=%s\r\n", buf); |
| 115 | } else { |
| 116 | printf("ctime: error(%s)\r\n", acl_last_serror()); |
| 117 | } |
| 118 | |
| 119 | local_time = localtime(&sbuf.st_atime); |
| 120 | if (local_time) { |
| 121 | strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", local_time); |
| 122 | printf("����ʱ�䣬atime=%s\r\n", buf); |
| 123 | } else { |
| 124 | printf("atime: error(%s)\r\n", acl_last_serror()); |
| 125 | } |
| 126 | |
| 127 | int ch, ch1; |
| 128 | |
| 129 | ch = ACL_VSTREAM_GETC(fp); |
| 130 | ch = 'a'; |
| 131 | |
| 132 | for (int i = 0; i < 100; i++) { |
| 133 | ch1 = ACL_VSTREAM_PUTC(ch, fp); |
no test coverage detected
searching dependent graphs…