当前位置: 首页>>代码示例>>C++>>正文


C++ FILE::size方法代码示例

本文整理汇总了C++中FILE::size方法的典型用法代码示例。如果您正苦于以下问题:C++ FILE::size方法的具体用法?C++ FILE::size怎么用?C++ FILE::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FILE的用法示例。


在下文中一共展示了FILE::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strlen

void
processCCO(SnapConConMesg *cco) {
  int   *contigGapToUngap   = NULL;
  int    contigLengthGapped = strlen(cco->consensus);
  int    contigLengthUngap  = 0;
  int    i = 0, j = 0;
  int    isDegenerate = 0;

  //  By definition, a degenerate contig has one unitig and is unplaced.
  //  In reality, those two conditions always occur together.
  //
  FILE  *len = ctglen;
  FILE  *frg = frgctg;
  FILE  *utg = utgctg;
  FILE  *var = varctg;

  if ((cco->placed == AS_UNPLACED) && (cco->num_unitigs == 1)) {
    isDegenerate = 1;
    len = deglen;
    frg = frgdeg;
    utg = utgdeg;
    var = vardeg;
  }


  contigGapToUngap = (int *)safe_calloc(contigLengthGapped + 1, sizeof(int));

  contigGapToUngap[0] = 0;

  for (i=0; i<contigLengthGapped; i++) {
    if (cco->consensus[i] != '-')
      contigLengthUngap++;
    contigGapToUngap[i+1] = contigLengthUngap;
  }

  fprintf(len, "%s\t%d\n",
          AS_UID_toString(cco->eaccession),
          contigLengthUngap);

  if (isDegenerate == 0)
    fprintf(ctginf, "%s\t%d\t%d\t%d\t%d\n",
            AS_UID_toString(cco->eaccession),
            contigLengthUngap,
            cco->num_unitigs,
            cco->num_pieces,
            cco->num_vars);
  else
    fprintf(deginf, "%s\t%d\t%d\t%d\t%d\t%s\t%f\t%f\n",
            AS_UID_toString(cco->eaccession),
            contigLengthUngap,
            cco->num_unitigs,
            cco->num_pieces,
            cco->num_vars,
            AS_UID_toString(cco->unitigs[0].eident),
            covStat[cco->unitigs[0].eident],
            microHet[cco->unitigs[0].eident]);

  uid2iid[cco->eaccession] = cco->iaccession;

  if (ctgInfoMax <= cco->iaccession) {
    ctgInfoMax *= 2;
    ctgInfo     = (ctgInfo_t *)safe_realloc(ctgInfo, ctgInfoMax * sizeof(ctgInfo_t));
  }
  ctgInfo[cco->iaccession].len = contigLengthUngap;

  //  VAR/variants
  for (i=0; i<cco->num_vars; i++) {
    IntMultiVar *v = cco->vars + i;

    int  bgn = contigGapToUngap[v->position.bgn];
    int  end = contigGapToUngap[v->position.end];

    fprintf(var, "%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%s\n",
            v->enc_var_seq,
            AS_UID_toString(cco->eaccession),
            bgn, end,
            v->num_reads,
            v->num_alleles_confirmed,
            v->min_anchor_size,
            v->var_length,
            v->enc_num_reads,
            v->enc_weights,
            v->enc_read_ids);
  }

  //  Remember what fragments were placed.  This is used to ignore
  //  some fragments when reporting unplaced surrogate fragments.

  set<AS_UID>  placed;

  //  MPS/fragments
  for (i=0; i<cco->num_pieces; i++) {
    int  bgn = contigGapToUngap[cco->pieces[i].position.bgn];
    int  end = contigGapToUngap[cco->pieces[i].position.end];
    char ori = ORIF;

    //  If bgn == end, then the fragment fell entirely within a gap.

    if (cco->pieces[i].position.bgn > cco->pieces[i].position.end) {
      ori = ORIR;
//.........这里部分代码省略.........
开发者ID:cdunn2001,项目名称:DConvert,代码行数:101,代码来源:buildPosMap.C

示例2: refresh_most

void VmBase::refresh_most()
{
    vm_ids_.clear();
    stable_vmthread_id_to_vm_id_.clear();
    name_.clear();
    uuid_.clear();
    vsocket_num_.clear();
    vcore_num_.clear();
    vhpthread_num_.clear();
    total_mem_size_.clear();

    string cmd = "ps -C " + vm_cmd_ + " -wwo etime=,pid=,args=";
    time_t cur_time;
    time(&cur_time);
    FILE* data = popen(cmd.c_str(), "r");

    string pid;
    string start_timestamp;
    vector<string> args;
    string tmp_str;
    while(fgets(buf_.get(), BUF_SIZE, data))
    {
        args.clear();
        istringstream is(buf_.get());
        is >> start_timestamp;

        long long days = 0;
        long long  hours = 0;
        long long  minutes = 0;
        long long  seconds = 0;
        time_t start_time;
        if (count(start_timestamp.begin(), start_timestamp.end(), '-') > 0)
            sscanf(start_timestamp.c_str(), "%lld-%lld:%lld:%lld", &days, &hours, &minutes, &seconds);
        else if (count(start_timestamp.begin(), start_timestamp.end(), ':') == 2)
            sscanf(start_timestamp.c_str(), "%lld:%lld:%lld", &hours, &minutes, &seconds);
        else if (count(start_timestamp.begin(), start_timestamp.end(), ':') == 1)
            sscanf(start_timestamp.c_str(), "%lld:%lld", &minutes, &seconds);
        start_time = cur_time - (((days * 24 + hours) * 60 + minutes) * 60 + seconds);

        is >> pid;
        while(is)
        {
            is >> tmp_str;
            args.push_back(tmp_str);
        }

        //add vm_ids
        VmId vm_id(start_time, stoull(pid));
        vm_ids_.insert(vm_id);

        //add name
        string name = "";
        auto name_iter = find(args.begin(), args.end(), "-name");
        if (name_iter != args.end())
        {
            ++name_iter;
            name = *name_iter;
        }
        else
        {
            //TODO throw //because of cgroup need it
        }
        name_[vm_id] = name;

        //add uuid
        string uuid = "";
        auto uuid_iter = find(args.begin(), args.end(), "-uuid");
        if (uuid_iter != args.end())
        {
            ++uuid_iter;
            uuid = *uuid_iter;
        }
        uuid_[vm_id] = uuid;

        //add vsocket vcore vhpthread
        auto iter = find(args.begin(), args.end(), "-smp");
        if (iter != args.end())
        {
            ++iter;
            vector<string> ops;
            str_tools::split(*iter, ',', ops);
            for(auto& op : ops)
            {
                vector<string> data;
                str_tools::split(op, '=', data);
                if (data.size() == 2) {
                    if(data[0] == "sockets")
                        vsocket_num_[vm_id] = stoi(data[1]);
                    else if(data[0] == "cores")
                        vcore_num_[vm_id] = stoi(data[1]);
                    else if(data[0] == "threads")
                        vhpthread_num_[vm_id] = stoi(data[1]);
                }
            }
        }

        //add total_mem_size
        int size = -1;
        auto size_iter = find(args.begin(), args.end(), "-m");
        if (size_iter != args.end())
//.........这里部分代码省略.........
开发者ID:chetui,项目名称:libvsf,代码行数:101,代码来源:vm_base.cpp


注:本文中的FILE::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。