File-Util

Defines additional functions like load_file and save_file.

Summary
File-UtilDefines additional functions like load_file and save_file.
CopyrightThis program is free software.
Files
C-kern/api/io/filesystem/fileutil.hHeader file File-Util.
C-kern/io/filesystem/fileutil.cImplementation file File-Util impl.
Functions
load_fileLoads content of file and appends it to result.
save_fileCreates file and writes file_content into it.
test
unittest_io_fileutilTest additional functionality implemented for file_t.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/io/filesystem/fileutil.h

Header file File-Util.

C-kern/io/filesystem/fileutil.c

Implementation file File-Util impl.

Functions

Summary
load_fileLoads content of file and appends it to result.
save_fileCreates file and writes file_content into it.
test
unittest_io_fileutilTest additional functionality implemented for file_t.

load_file

int load_file(const char *filepath,
/*ret*/struct wbuffer_t *result,
struct directory_t *relative_to)

Loads content of file and appends it to result.

Returns

0File content loaded and appended to result.
ENOENTFile does not exist.  Nothing was done.
EIOLoading error occurred - result was cleared.

save_file

int save_file(const char *filepath,
size_t file_size,
const void *file_content/*[filer_size]*/,
struct directory_t *relative_to)

Creates file and writes file_content into it.

Returns

0File created and file_size bytes of file_content written into it.
EEXISTFile already exists.  Nothing was done.
EIOFile created and deleted after a write error occurred.

test

unittest_io_fileutil

int unittest_io_fileutil(void)

Test additional functionality implemented for file_t.

int load_file(const char *filepath,
/*ret*/struct wbuffer_t *result,
struct directory_t *relative_to)
Loads content of file and appends it to result.
int save_file(const char *filepath,
size_t file_size,
const void *file_content/*[filer_size]*/,
struct directory_t *relative_to)
Creates file and writes file_content into it.
Defines additional functions like load_file and save_file.
Implements File-Util.
int unittest_io_fileutil(void)
Test additional functionality implemented for file_t.
typedef sys_iochannel_t file_t
Export file_t, alias for sys_iochannel_t.
Close