diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-07 10:02:58 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-07 10:02:58 +0000 |
commit | 525118dfe8bb3f6b874db7920dc0ee04eede0585 (patch) | |
tree | c2f57a84561e427c09ea7a248f438c187a004c58 /src/htsjava.c | |
parent | aad35562b3293c792e858b36c3ca7d1ab2f386c6 (diff) |
Charset fixes
Diffstat (limited to 'src/htsjava.c')
-rw-r--r-- | src/htsjava.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/htsjava.c b/src/htsjava.c index 335d378..e3af5ea 100644 --- a/src/htsjava.c +++ b/src/htsjava.c @@ -46,6 +46,7 @@ Please visit our Website: http://www.httrack.com #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #if ( defined(_WIN32) ||defined(HAVE_SYS_TYPES_H) ) #include <sys/types.h> #endif @@ -136,16 +137,12 @@ static int hts_detect_java(t_hts_callbackarg *carg, httrackp *opt, } static off_t fsize(const char* s) { - FILE* fp; - fp=fopen(s,"rb"); - if (fp!=NULL) { - off_t i; - fseek(fp,0,SEEK_END); - i = ftell(fp); - fclose(fp); - return i; - } else + STRUCT_STAT st; + if (STAT(s, &st) == 0 && S_ISREG(st.st_mode)) { + return st.st_size; + } else { return -1; + } } static int hts_parse_java(t_hts_callbackarg *carg, httrackp *opt, @@ -174,7 +171,7 @@ static int hts_parse_java(t_hts_callbackarg *carg, httrackp *opt, #if JAVADEBUG printf("fopen\n"); #endif - if ((fpout = fopen(fconv(catbuff, file), "r+b")) == NULL) + if ((fpout = FOPEN(fconv(catbuff, file), "r+b")) == NULL) { //fprintf(stderr, "Cannot open input file.\n"); sprintf(str->err_msg,"Unable to open file %s",file); |