It turns out that g_stat() breaks apart when using 64 bit stat on
32-bit systems. Since the actual type of GStatBuf is decided when
glib/gstdio.h is included, it is thus possible for GLib itself to
be compiled with a different type than user code.
Ouch. Unfortunately going back to plain stat() also means that we
lose Unicode filename support on Windows.
const char *filename)
{
FILE *fw;
- GStatBuf st;
+ struct stat st;
struct sr_usb_dev_inst *usb;
int chunksize, result, ret;
unsigned char *buf;
sr_dbg("Uploading FPGA firmware at %s.", filename);
usb = sdi->conn;
- if (g_stat(filename, &st) < 0) {
+ if (stat(filename, &st) < 0) {
sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno));
return SR_ERR;
}
#include <config.h>
#include <errno.h>
+#include <sys/stat.h>
#include <glib/gstdio.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
*/
static unsigned char *load_bitstream_file(const char *filename, int *length_p)
{
- GStatBuf statbuf;
+ struct stat statbuf;
FILE *file;
unsigned char *stream;
size_t length, count;
/* Retrieve and validate the file size. */
- if (g_stat(filename, &statbuf) < 0) {
+ if (stat(filename, &statbuf) < 0) {
sr_err("Failed to access bitstream file: %s.",
g_strerror(errno));
return NULL;