Ejemplo n.º 1
0
GtMatchIterator* gt_match_iterator_open_new(const char *matchfile, GtError *err)
{
  GtMatchIterator *mp;
  GtMatchIteratorOpen *mpo;
  mp = gt_match_iterator_create(gt_match_iterator_open_class());
  mpo = (GtMatchIteratorOpen*) mp;
  mpo->pvt = gt_calloc(1, sizeof (GtMatchIteratorOpenMembers));
  GtFileMode mode;
  if (gt_file_exists(matchfile)) {
    mode = gt_file_mode_determine(matchfile);
    if (mode == GT_FILE_MODE_UNCOMPRESSED) {
      mpo->pvt->matchfilep = fopen(matchfile, "r");
      mpo->pvt->gtmatchfilep = NULL;
      if (!mpo->pvt->matchfilep) {
        gt_error_set(err, "Could not open %s", matchfile);
        return NULL;
      }
    } else {
      mpo->pvt->gtmatchfilep = gt_file_open(mode, matchfile, "r", err);
      mpo->pvt->matchfilep = NULL;
      if (!mpo->pvt->gtmatchfilep)
        return NULL;
    }
    mpo->pvt->matchfile = matchfile;
    return mp;
  } else {
    gt_error_set(err, "No such file or directory %s", matchfile);
    return NULL;
  }
}
Ejemplo n.º 2
0
off_t gt_file_estimate_size(const char *file)
{
  off_t size;
  struct stat sb;
  GtFileMode gfm;
  int fd;

  gt_assert(file);

  fd = gt_xopen(file, O_RDONLY, 0);
  gt_xfstat(fd, &sb);
  gfm = gt_file_mode_determine(file);
  if (gfm == GT_FILE_MODE_UNCOMPRESSED)
    size = sb.st_size;
  else
    size = sb.st_size  * 4; /* expected compression rate for sequence is 0.25 */
  gt_xclose(fd);

  return size;
}
Ejemplo n.º 3
0
GtFile* gt_file_new(const char *path, const char *mode, GtError *err)
{
  gt_error_check(err);
  gt_assert(mode);
  return gt_file_open(gt_file_mode_determine(path), path, mode, err);
}
Ejemplo n.º 4
0
GtFile* gt_file_xopen(const char *path, const char *mode)
{
  gt_assert(mode);
  return gt_file_xopen_file_mode(gt_file_mode_determine(path), path, mode);
}