common: file-helper: Remove unused code 11/199811/4 submit/tizen/20190215.113808
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 14 Feb 2019 14:34:10 +0000 (15:34 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 15 Feb 2019 11:12:33 +0000 (12:12 +0100)
Change-Id: Id0728f6acf74bd71289cf185f3ab165274b0d5f3

src/common/file-helper.c
src/common/file-helper.h

index f1326bb..7a30b3f 100644 (file)
@@ -34,9 +34,6 @@
 #include "macro.h"
 #include "util.h"
 
-#define BUF_MAX                (BUFSIZ)
-#define BUF_INC_SIZE   (512 << 10)
-
 int fwrite_str(const char *path, const char *str)
 {
        _cleanup_fclose_ FILE *f = NULL;
@@ -190,94 +187,3 @@ int fread_nth_ulong(const char *path, size_t n, unsigned long *number)
        *number = t;
        return RESOURCED_ERROR_NONE;
 }
-
-/* reads file contents into memory */
-char* cread(const char* path)
-{
-       char*   text = NULL;
-       size_t  size = 0;
-
-       ssize_t ret;
-       char*   ptr = text;
-       size_t  cap = size;
-       _cleanup_close_ int fd = -1;
-
-       assert(path);
-
-       fd = open(path, O_RDONLY);
-       if (fd < 0) {
-               _E("Failed to open %s: %m", path);
-               return NULL;
-       }
-
-       do {
-               /* ensure we have enough space */
-               if (cap == 0) {
-                       ptr = (char*)realloc(text, size + BUF_INC_SIZE);
-                       if (ptr == NULL) {
-                               ret = -1;
-                               break;
-                       }
-
-                       text  = ptr;
-                       ptr   = text + size;
-                       cap   = BUF_INC_SIZE;
-                       size += BUF_INC_SIZE;
-               }
-               ret = read(fd, ptr, cap);
-               if (ret == 0) {
-                       *ptr = 0;
-               } else if (ret > 0) {
-                       cap -= ret;
-                       ptr += ret;
-               } else
-                       free(text);
-       } while (ret > 0);
-
-       return (ret < 0 ? NULL : text);
-}
-
-/* like fgets/gets but adjusting contents pointer */
-char* cgets(char** contents)
-{
-       if (contents && *contents && **contents) {
-               char* bos = *contents;          /* begin of string */
-               char* eos = strchr(bos, '\n');  /* end of string   */
-
-               if (eos) {
-                       *contents = eos + 1;
-                       *eos      = 0;
-               } else {
-                       *contents = NULL;
-               }
-
-               return bos;
-       }
-
-       return NULL;
-}
-
-int copy_file(char *dest, char *src)
-{
-       _cleanup_fclose_ FILE *fps = NULL;
-       _cleanup_fclose_ FILE *fpd = NULL;
-       char buf[BUF_MAX];
-       size_t size;
-
-       fps = fopen(src, "rb");
-       if (fps == NULL) {
-               _E("Failed to open src file '%s': %m", src);
-               return -errno;
-       }
-
-       fpd = fopen(dest, "wb");
-       if (fpd == NULL) {
-               _E("Failed to open dest file '%s': %m", dest);
-               return -errno;
-       }
-
-       while ((size = fread(buf, 1, BUF_MAX, fps)))
-               fwrite(buf, 1, size, fpd);
-
-       return RESOURCED_ERROR_NONE;
-}
index 25b5503..c880b1d 100644 (file)
@@ -68,14 +68,4 @@ inline int fread_ulong(const char *path, unsigned long *number)
        return fread_nth_ulong(path, 0, number);
 }
 
-char *cread(const char *path);
-char *cgets(char **contents);
-
-/**
- * @desc copy file from src to dest
- * @param dest- destination file path, src- source file path
- * @return negative value if error
- */
-int copy_file(char *dest, char *src);
-
 #endif  /*_RESOURCED_FILE_HELPER_H_*/