Last change
on this file since 41 was 41, checked in by cheese, 11 years ago |
#1 add function to make directory and update file test code
|
File size:
732 bytes
|
Rev | Line | |
---|
[35] | 1 | /**
|
---|
| 2 | * @file file.c
|
---|
| 3 | * @author myusgun <myusgun@gmail.com>
|
---|
| 4 | * @version 0.1
|
---|
| 5 | */
|
---|
| 6 | #include "cf_file.h"
|
---|
| 7 | #include <stdio.h>
|
---|
| 8 |
|
---|
| 9 | int main (void) {
|
---|
| 10 | int fd = 0;
|
---|
[41] | 11 | char *dir1 = "./dir1/test";
|
---|
| 12 | char *dir2 = "dir2/test";
|
---|
[35] | 13 | char *name = "file.txt";
|
---|
| 14 | char buffer[128] = {0x00,};
|
---|
| 15 |
|
---|
[41] | 16 | if (CF_File_MakeDirectory (dir1)) {
|
---|
| 17 | // error
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | if (CF_File_MakeDirectory (dir2)) {
|
---|
| 21 | // error
|
---|
| 22 | }
|
---|
| 23 |
|
---|
[35] | 24 | fd = CF_File_Create (name);
|
---|
| 25 | if (fd < 0) {
|
---|
| 26 | // error
|
---|
| 27 | }
|
---|
| 28 | if (CF_File_Write (fd, "file test", 9) < 0) {
|
---|
| 29 | // error
|
---|
| 30 | }
|
---|
| 31 | CF_File_Close (fd);
|
---|
| 32 |
|
---|
| 33 | fd = CF_File_Open (name, CF_FILE_RO);
|
---|
| 34 | if (fd < 0) {
|
---|
| 35 | // error
|
---|
| 36 | }
|
---|
| 37 | printf ("file size : %d\n", CF_File_GetSize (fd));
|
---|
| 38 | if (CF_File_Read (fd, buffer, sizeof (buffer)) < 0) {
|
---|
| 39 | // error
|
---|
| 40 | }
|
---|
| 41 | CF_File_Close (fd);
|
---|
| 42 |
|
---|
| 43 | return 0;
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.