X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/23b80a733436e88426c2b857950674768eb2b8a2..d3a22c7dfa87bf5e21d228849a602194be4a0895:/client/loclass/fileutils.c diff --git a/client/loclass/fileutils.c b/client/loclass/fileutils.c index deab3137..443070c1 100644 --- a/client/loclass/fileutils.c +++ b/client/loclass/fileutils.c @@ -49,8 +49,14 @@ * @return */ int fileExists(const char *filename) { + +#ifdef _WIN32 struct _stat fileStat; int result = _stat(filename, &fileStat); +#else + struct stat fileStat; + int result = stat(filename, &fileStat); +#endif return result == 0; } @@ -73,6 +79,7 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si FILE *fh=fopen(fileName,"wb"); if(!fh) { PrintAndLog("Failed to write to file '%s'", fileName); + free(fh); return 1; } fwrite(data, 1, datalen, fh); @@ -88,10 +95,12 @@ int loadFile(const char *fileName, void* data, size_t datalen) FILE *filehandle = fopen(fileName, "rb"); if(!filehandle) { PrintAndLog("Failed to read from file '%s'", fileName); + free(filehandle); return 1; } fread(data,datalen,1,filehandle); fclose(filehandle); + free(filehandle); return 0; } /**