source: libcf/trunk/test/file.c@ 151

Last change on this file since 151 was 151, checked in by cheese, 11 years ago

#1 fix interface and add util module

File size: 805 bytes
RevLine 
[35]1/**
2 * @file file.c
3 * @author myusgun <myusgun@gmail.com>
4 */
5#include "cf_file.h"
6#include <stdio.h>
7
[151]8int main (void)
9{
10 cf_ctx fd = 0;
11 int result = 0;
[41]12 char *dir1 = "./dir1/test";
13 char *dir2 = "dir2/test";
[35]14 char *name = "file.txt";
15 char buffer[128] = {0x00,};
16
[41]17 if (CF_File_MakeDirectory (dir1)) {
18 // error
19 }
20
21 if (CF_File_MakeDirectory (dir2)) {
22 // error
23 }
24
[151]25 result = CF_File_Open (&fd, name, CF_FILE_CREATE|CF_FILE_RW|CF_FILE_TRUNC);
26 if (result < 0) {
[35]27 // error
28 }
29 if (CF_File_Write (fd, "file test", 9) < 0) {
30 // error
31 }
32 CF_File_Close (fd);
33
[151]34 result = CF_File_Open (&fd, name, CF_FILE_READ);
35 if (result < 0) {
[35]36 // error
37 }
[94]38 printf ("file size : %d\n", CF_File_GetSize (name));
[35]39 if (CF_File_Read (fd, buffer, sizeof (buffer)) < 0) {
40 // error
41 }
42 CF_File_Close (fd);
43
44 return 0;
45}
Note: See TracBrowser for help on using the repository browser.