static void test_write_permissions(void) { #if defined(_MSC_VER) #else struct MZ_FILE_STAT_STRUCT file_stats; const char *filenames[] = {WFILE}; FILE *f = fopen(WFILE, "w"); fclose(f); chmod(WFILE, WMODE); remove(ZIPNAME); assert(0 == zip_create(ZIPNAME, filenames, 1)); remove(WFILE); assert(0 == zip_extract(ZIPNAME, ".", NULL, NULL)); assert(0 == MZ_FILE_STAT(WFILE, &file_stats)); assert(WMODE == file_stats.st_mode); remove(WFILE); remove(ZIPNAME); #endif }
static void test_read_permissions(void) { #if defined(_MSC_VER) #else struct MZ_FILE_STAT_STRUCT file_stats; const char *filenames[] = {RFILE}; FILE *f = fopen(RFILE, "w"); fclose(f); chmod(RFILE, RMODE); remove(ZIPNAME); assert(0 == zip_create(ZIPNAME, filenames, 1)); // chmod from 444 to 666 to be able delete the file on windows chmod(RFILE, WMODE); remove(RFILE); assert(0 == zip_extract(ZIPNAME, ".", NULL, NULL)); assert(0 == MZ_FILE_STAT(RFILE, &file_stats)); assert(RMODE == file_stats.st_mode); chmod(RFILE, WMODE); remove(RFILE); remove(ZIPNAME); #endif }
static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet, GString **out) { struct out_context *outc; const struct sr_datafeed_meta *meta; const struct sr_datafeed_logic *logic; const struct sr_config *src; GSList *l; int ret; *out = NULL; if (!o || !o->sdi || !(outc = o->priv)) return SR_ERR_ARG; switch (packet->type) { case SR_DF_META: meta = packet->payload; for (l = meta->config; l; l = l->next) { src = l->data; if (src->key != SR_CONF_SAMPLERATE) continue; outc->samplerate = g_variant_get_uint64(src->data); } break; case SR_DF_LOGIC: if (!outc->zip_created) { if ((ret = zip_create(o)) != SR_OK) return ret; outc->zip_created = TRUE; } logic = packet->payload; ret = zip_append(o, logic->data, logic->unitsize, logic->length); if (ret != SR_OK) return ret; break; } return SR_OK; }
static void test_exe_permissions(void) { #if defined(_WIN32) || defined(__WIN32__) #else struct MZ_FILE_STAT_STRUCT file_stats; const char *filenames[] = {XFILE}; FILE *f = fopen(XFILE, "w"); fclose(f); chmod(XFILE, XMODE); remove(ZIPNAME); assert(0 == zip_create(ZIPNAME, filenames, 1)); remove(XFILE); assert(0 == zip_extract(ZIPNAME, ".", NULL, NULL)); assert(0 == MZ_FILE_STAT(XFILE, &file_stats)); assert(XMODE == file_stats.st_mode); remove(XFILE); remove(ZIPNAME); #endif }