// Can only delegate (chain) constructors since C++11 Condition::Condition(Buffer& b) : ECBase(CONDITION), pUnit(NULL), pTech(NULL), valid_since_last_check(true) { memcpy(&amount, defaultvals, sizeof(defaultvals)); ClipboardType::Value cliptype; b.read(&cliptype, sizeof(cliptype)); if (cliptype != ClipboardType::CONDITION) throw bad_data_error("Condition has incorrect check value."); b.read(&type, sizeof(type)); b.read(&size, sizeof(size)); if (size >= 0) { long * flatdata = new long[size]; b.read(flatdata, sizeof(long) * size); memcpy(&amount, flatdata, sizeof(long) * (size<=MAXFIELDS?size:MAXFIELDS)); delete[] flatdata; } if (size >= 5) pUnit = esdata.units.getByIdSafe(unit_cnst); if (size >= 7) pTech = esdata.techs.getByIdSafe(tech_cnst); check_and_save(); }
static int dlorean_open(const char *path, struct fuse_file_info *fi) { int n; char *path_t; samefs(real_path, mount_point_path); /* The line below doesn't work :(. Perhaps i should check only "readonly" * flag in an open operation */ //if ((fi->flags == O_WRONLY) || (fi->flags == O_RDWR)) /* * if ((fi->flags > O_RDONLY)) * save_a_copy(path); */ /* When i open some files (if they already exist) the flags * are 32768 (with "more" for example) or > 32768. * Is read only 0 only? */ int time = in_the_past(fuse_get_context()->pid); if (time > 0) path_t=get_fn(path, time); else { check_and_save(path); path_t = strcatloc(real_path, path); }; n = open (path_t, fi->flags); free(path_t); if (n == -1) { perror("open"); return -EACCES; } fi->fh = n; return 0; }
void Condition::read(FILE *in) { memcpy(&amount, defaultvals, sizeof(defaultvals)); readbin(in, &type); readbin(in, &size); if (size < 0 || size > MAXFIELDS) throw bad_data_error("Condition has incorrect size value."); size_t read = fread(&amount, sizeof(long), size, in); if (read != (size_t)size) { throw bad_data_error( (feof(in)) ? "Early EOF" : "stream error"); } if (size >= 5) pUnit = esdata.units.getByIdSafe(unit_cnst); if (size >= 7) pTech = esdata.techs.getByIdSafe(tech_cnst); check_and_save(); }