* @return
*/
int fileExists(const char *filename) {
- struct _stat fileStat;
- int result = _stat(filename, &fileStat);
+
+#ifdef _WIN32
+ struct _stat st;
+ int result = _stat(filename, &st);
+#else
+ struct stat st;
+ int result = stat(filename, &st);
+#endif
return result == 0;
}
FILE *fh=fopen(fileName,"wb");
if(!fh) {
PrintAndLog("Failed to write to file '%s'", fileName);
+ free(fh);
return 1;
}
fwrite(data, 1, datalen, fh);
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;
}
/**
*/
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);
+
}