From 33d2b15a907f308fe65b38ba8ff9c29947bf4947 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Wed, 24 Apr 2013 13:22:59 +0200 Subject: [PATCH] src/system/helpers.cpp:-add file_size function Signed-off-by: Jacek Jendrzej Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/947a277a49c5e18298677c759f702e41d9b44a92 Author: Jacek Jendrzej Date: 2013-04-24 (Wed, 24 Apr 2013) ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 12 ++++++++++++ src/system/helpers.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index d3957201a..df41e86db 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -42,6 +42,18 @@ #include #include +off_t file_size(const char *filename) +{ + struct stat stat_buf; + if(::stat(filename, &stat_buf) == 0) + { + return stat_buf.st_size; + } else + { + return 0; + } +} + bool file_exists(const char *filename) { struct stat stat_buf; diff --git a/src/system/helpers.h b/src/system/helpers.h index c87adb71f..a811edab8 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -27,6 +27,7 @@ int my_system(int argc, const char *arg, ...); /* argc is number of arguments in FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type); int safe_mkdir(char * path); +off_t file_size(const char *filename); bool file_exists(const char *filename); void wakeup_hdd(const char *hdd_dir); int check_dir(const char * dir);