Move fwrite_array() next to other write functions 17/179817/1
authorŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 22 May 2018 10:03:38 +0000 (12:03 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 22 May 2018 12:11:29 +0000 (14:11 +0200)
Change-Id: I62c6b0dcaa8d92b4b8de01e27b5b38a8157208fa
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/common/file-helper.c
src/common/file-helper.h

index 0cb3bb0a45b5a8043466a39b872dfe4899249e2e..bc52d15a8d23fd9e10f33fc4a891f7e25413c28c 100644 (file)
@@ -92,6 +92,27 @@ int fwrite_ulong(const char *path, const unsigned long number)
        return fwrite_str(path, digit_buf);
 }
 
+int fwrite_array(const char *path, const void *array,
+                const size_t size_of_elem,
+                const size_t numb_of_elem)
+{
+       _cleanup_fclose_ FILE *f = NULL;
+       int ret;
+
+       assert(path);
+       assert(array);
+
+       f = fopen(path, "w");
+       ret_value_errno_msg_if(!f, -errno,
+                              "Failed open %s file", path);
+
+       ret = fwrite(array, size_of_elem, numb_of_elem, f);
+       ret_value_errno_msg_if(ret != numb_of_elem, -errno,
+                              "Failed write array into %s file", path);
+
+       return RESOURCED_ERROR_NONE;
+}
+
 int fread_str(const char *path, char **str)
 {
        _cleanup_fclose_ FILE *f = NULL;
@@ -155,27 +176,6 @@ int fread_ulong(const char *path, unsigned long *number)
        return RESOURCED_ERROR_NONE;
 }
 
-int fwrite_array(const char *path, const void *array,
-                const size_t size_of_elem,
-                const size_t numb_of_elem)
-{
-       _cleanup_fclose_ FILE *f = NULL;
-       int ret;
-
-       assert(path);
-       assert(array);
-
-       f = fopen(path, "w");
-       ret_value_errno_msg_if(!f, -errno,
-                              "Failed open %s file", path);
-
-       ret = fwrite(array, size_of_elem, numb_of_elem, f);
-       ret_value_errno_msg_if(ret != numb_of_elem, -errno,
-                              "Failed write array into %s file", path);
-
-       return RESOURCED_ERROR_NONE;
-}
-
 /* reads file contents into memory */
 char* cread(const char* path)
 {
index 0b932e81ef30149740dc1cfbf9d2c9cfcfd61f8a..9de417f425ddacadc67699c0033f3225c770f633 100644 (file)
@@ -41,6 +41,10 @@ int fwrite_uint(const char *path, const u_int32_t number);
 
 int fwrite_ulong(const char *path, const unsigned long number);
 
+int fwrite_array(const char *path, const void *array,
+                const size_t size_of_elem,
+                const size_t numb_of_elem);
+
 int fread_str(const char *path, char **str);
 
 int fread_int(const char *path, int32_t *number);
@@ -49,10 +53,6 @@ int fread_uint(const char *path, u_int32_t *number);
 
 int fread_ulong(const char *path, unsigned long *number);
 
-int fwrite_array(const char *path, const void *array,
-                const size_t size_of_elem,
-                const size_t numb_of_elem);
-
 char *cread(const char *path);
 char *cgets(char **contents);