Skip to content
Snippets Groups Projects
Commit 82de2c8f authored by raphael.bach's avatar raphael.bach
Browse files

Add FIO_Write() in file_io.h

parent f8306478
Branches
No related tags found
No related merge requests found
......@@ -53,6 +53,10 @@ int FIO_Close(int fd);
FIO_Read()
------------------------------------------------------------------------------*/
size_t FIO_Read(int fd, void * buffer, size_t count);
/*------------------------------------------------------------------------------
FIO_Write()
------------------------------------------------------------------------------*/
size_t FIO_Write(int fd, const void * buffer, size_t count);
/*------------------------------------------------------------------------------
FIO_GetSize()
------------------------------------------------------------------------------*/
......
......@@ -43,7 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <fcntl.h> // open()
#include <sys/stat.h> // fstat()
#include <sys/types.h> // mode_t, off_t
#include <unistd.h> // close(), lseek()
#include <unistd.h> // close(), read(), lseek()
// Internal
#include "log.h"
/*==============================================================================
......@@ -110,6 +110,21 @@ size_t FIO_Read(int fd, void * buffer, size_t count)
}
return (size_t)bytes_read;
}
/*------------------------------------------------------------------------------
FIO_Write()
------------------------------------------------------------------------------*/
size_t FIO_Write(int fd, const void * buffer, size_t count)
{
assert(buffer != NULL);
ssize_t bytes_written = write(fd, buffer, count);
if(bytes_written != -1) {
} else {
Log_Fatal(&s_logger, "write(%d) failed! %s", fd, strerror(errno));
exit(-1);
}
return (size_t)bytes_written;
}
/*------------------------------------------------------------------------------
FIO_GetSize()
------------------------------------------------------------------------------*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment