/*
- * Copyright (C) 2010-2014 jeanfi@gmail.com
+ * Copyright (C) 2010-2016 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#include <pio.h>
/* Directory separator is \ when cross-compiling for MS Windows
- systems */
+ * systems
+ */
#if defined(__MINGW32__)
#define DIRSEP ('\\')
#else
return 0;
}
-char *dir_normalize(const char *dpath)
+static char *dir_normalize(const char *dpath)
{
char *npath;
int n;
} else {
FILE *fp = fopen(fpath, "rb");
+
if (fp) {
page = malloc(size + 1);
if (!page || size != fread(page, 1, size, fp)) {
free(page);
- return NULL;
+ page = NULL;
+ } else {
+ *(page + size) = '\0';
}
- *(page + size) = '\0';
-
fclose(fp);
} else {
page = NULL;
long file_get_size(const char *path)
{
FILE *fp;
+ long size;
if (!is_file(path))
return -1;
fp = fopen(path, "rb");
if (fp) {
- long size;
-
if (fseek(fp, 0, SEEK_END) == -1)
- return -1;
-
- size = ftell(fp);
+ size = -1;
+ else
+ size = ftell(fp);
fclose(fp);
-
- return size;
+ } else {
+ size = -1;
}
- return -1;
+ return size;
}
#define FCOPY_BUF_SZ 4096