diff --git a/src/ecma119.c b/src/ecma119.c index 60c7dbf..ee05ada 100644 --- a/src/ecma119.c +++ b/src/ecma119.c @@ -20,6 +20,7 @@ #include #include #include +#include static void ecma119_image_free(Ecma119Image *t) @@ -329,4 +330,15 @@ int iso_image_create(IsoImage *image, Ecma119WriteOpts *opts, return ISO_SUCCESS; } - +int iso_write(Ecma119Image *target, void *buf, size_t count) +{ + ssize_t result; + + result = write(target->wrfd, buf, count); + if (result != count) { + /* treat this as an error? */ + return ISO_WRITE_ERROR; + } else { + return ISO_SUCCESS; + } +} diff --git a/src/ecma119.h b/src/ecma119.h index 3a4571b..0288e20 100644 --- a/src/ecma119.h +++ b/src/ecma119.h @@ -71,6 +71,10 @@ struct ecma119_image { /* tree of files sources */ void *file_srcs; int file_count; + + /* file descriptors for read and writing image */ + int wrfd; /* write to here */ + int rdfd; /* read from here */ }; #endif /*LIBISO_ECMA119_H_*/ diff --git a/src/error.h b/src/error.h index 7907346..a69e177 100644 --- a/src/error.h +++ b/src/error.h @@ -21,6 +21,8 @@ #define ISO_INTERRUPTED -5 #define ISO_WRONG_ARG_VALUE -6 +#define ISO_WRITE_ERROR -10 + #define ISO_NODE_ALREADY_ADDED -50 #define ISO_NODE_NAME_NOT_UNIQUE -51 #define ISO_NODE_NOT_ADDED_TO_DIR -52 diff --git a/src/writer.h b/src/writer.h index af61471..0db97be 100644 --- a/src/writer.h +++ b/src/writer.h @@ -27,6 +27,18 @@ struct Iso_Image_Writer Ecma119Image *target; }; +/** + * This is the function all Writers shoudl call to write data to + * image. + * Currently, it is just a wrapper for write(2) Unix system call. + * + * It is implemented in ecma119.c + * + * @return + * 1 on sucess, < 0 error + */ +int iso_write(Ecma119Image *target, void *buf, size_t count); + int ecma119_writer_create(Ecma119Image *target); #endif /*LIBISO_IMAGE_WRITER_H_*/