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

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

#1 change interface to get file size

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