X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f97d4e2378e04397b3c884d10acb79725dee4e06..4888b2819574627efea9bd7d23444d785c5a2077:/client/loclass/fileutils.c diff --git a/client/loclass/fileutils.c b/client/loclass/fileutils.c index 2f7b6b65..206d9695 100644 --- a/client/loclass/fileutils.c +++ b/client/loclass/fileutils.c @@ -11,14 +11,20 @@ * @return */ int fileExists(const char *filename) { + +#ifdef _WIN32 + struct _stat st; + int result = _stat(filename, &st); +#else struct stat st; int result = stat(filename, &st); +#endif return result == 0; } int saveFile(const char *preferredName, const char *suffix, const void* data, size_t datalen) { - int size = sizeof(char) * (strlen(preferredName)+strlen(suffix)+5); + int size = sizeof(char) * (strlen(preferredName)+strlen(suffix)+10); char * fileName = malloc(size); memset(fileName,0,size); @@ -34,12 +40,14 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si /*Opening file for writing in binary mode*/ FILE *fileHandle=fopen(fileName,"wb"); if(!fileHandle) { - prnlog("Failed to write to file '%s'", fileName); + PrintAndLog("Failed to write to file '%s'", fileName); + free(fileName); return 1; } fwrite(data, 1, datalen, fileHandle); fclose(fileHandle); - prnlog("Saved data to '%s'", fileName); + PrintAndLog("Saved data to '%s'", fileName); + free(fileName); return 0; @@ -55,11 +63,11 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si */ void prnlog(char *fmt, ...) { - + char buffer[2048] = {0}; va_list args; va_start(args,fmt); - PrintAndLog(fmt, args); - //vprintf(fmt,args); + vsprintf (buffer,fmt, args); va_end(args); - //printf("\n"); + PrintAndLog(buffer); + }