/** Check file existance */ static bool SpotIteratorFileExists(const char* path, ...) { bool found = false; if (SpotIteratorInitDirectory() == 0) { uint32_t type va_list args; va_start(args, path); type = KDirectoryVPathType(__SpotIteratorDirectory, path, args); found = (type != kptNotFound); va_end(args); } return found; }
static rc_t SpotIteratorInit(struct SpotIterator* self, const SRATable* tbl, const char* redactFileName) { rc_t rc = 0; assert(self && tbl && redactFileName); memset(self, 0, sizeof *self); self->m_crnSpotId = 1; rc = SRATableMaxSpotId(tbl, &self->m_maxSpotId); if (rc != 0) { logerr(klogErr, rc, "while calling SRATableMaxSpotId"); } else { plogmsg(klogInfo, "MaxSpotId = $(spot)", PLOG_U32(spot), self->m_maxSpotId); } if (rc == 0) { rc = SpotIteratorInitDirectory(); } if (rc == 0) { self->m_filename = redactFileName; plogmsg(klogInfo, "Opening '$(path)'", "path=%s", self->m_filename); rc = KDirectoryOpenFileRead( __SpotIteratorDirectory, &self->m_file, "%s", self->m_filename); if (rc != 0) { plogerr(klogErr, rc, "while opening file '$(path)'", "path=%s", self->m_filename); } } if (rc == 0) { rc = SpotIteratorReadSpotToRedact(self); } return rc; }
static rc_t SpotIteratorInit(const char* redactFileName, const Db* db, SpotIterator* self) { rc_t rc = 0; int64_t first = 0; assert(self && db); memset(self, 0, sizeof *self); self->crnSpotId = 1; rc = VCursorIdRange (db->rCursor, db->rFilterIdx, &first, &self->maxSpotId); DISP_RC(rc, "while calling VCursorIdRange"); self->spotToReduct = first - 1; if (rc == 0) { rc = SpotIteratorInitDirectory(); } if (rc == 0) { self->filename = redactFileName; rc = KDirectoryOpenFileRead (__SpotIteratorDirectory, &self->file, "%s", self->filename); if (rc != 0) { PLOGERR(klogErr, (klogErr, rc, "while opening file '$(path)'", "path=%s", self->filename)); } } if (rc == 0) { rc = SpotIteratorReadSpotToRedact(self); } return rc; }