aboutsummaryrefslogtreecommitdiffstats
path: root/src/file/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file/file.c')
-rw-r--r--src/file/file.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/file/file.c b/src/file/file.c
index 862c1ea..db37b25 100644
--- a/src/file/file.c
+++ b/src/file/file.c
@@ -6,20 +6,13 @@
*/
#include <sys/stat.h>
+#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "file.h"
+#include "error.h"
-/* get_file_size: return size of file with filename 'name' */
-uint64_t get_file_size(char *name)
-{
- uint64_t size;
- struct stat st;
- stat(name, &st);
- size = st.st_size;
- return size;
-}
/* open_file: open file and return pointer to the file if it exists. */
FILE *open_file(char *name, char *mode)
@@ -27,8 +20,16 @@ FILE *open_file(char *name, char *mode)
FILE *fp;
fp = fopen(name, mode);
if (fp == NULL) {
- perror("cant open file");
+ error(errno, "cant open file");
exit(1);
}
return fp;
}
+
+/* get_file_info: return struct with info about file */
+struct stat *get_file_info(char *name)
+{
+ struct stat *stbuf = malloc(sizeof(struct stat));
+ stat(name, stbuf);
+ return stbuf;
+}