Example #1
0
//___________________________________________________________________
void MakeFileList(const char *searchdir, const char *pattern, const char* outputFileName="calib.list", Int_t timeOut=10)
{
  gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut));
  gEnv->SetValue("XNet.RequestTimeout", timeOut);
  gEnv->SetValue("XNet.ConnectTimeout", timeOut);
  gEnv->SetValue("XNet.TransactionTimeout", timeOut);
  TFile::SetOpenTimeout(timeOut);

  TGrid::Connect("alien");

  TString command;
  command = Form("find %s %s", searchdir, pattern);
  cerr<<"command: "<<command<<endl;
  TGridResult *res = gGrid->Command(command);
  if (!res) return;
  TIter nextmap(res);
  TMap *map = 0;

  ofstream outputFile;
  outputFile.open(Form(outputFileName));

  //first identify the largest file and put it at the beginning
  Int_t largestFileSize=0;
  TString largestFile;
  TObject* largestObject;
  while((map=(TMap*)nextmap()))
  {
    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
    TObjString *objsSize = dynamic_cast<TObjString*>(map->GetValue("size"));
    if (!objs || !objs->GetString().Length()) continue;
    if (!objsSize || !objsSize->GetString().Length()) continue;

    Int_t currentFileSize=objsSize->GetString().Atoi();
    if (currentFileSize>largestFileSize) 
    {
      largestFileSize=currentFileSize;
      largestFile=objs->GetString();
      largestObject=map;
    }
  }
  outputFile << largestFile.Data()<< endl;
  res->Remove(largestObject);
  
  //then write the rest of the entries to the file
  nextmap.Reset();
  while((map=(TMap*)nextmap()))
  {
    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
    if (!objs || !objs->GetString().Length())
    {
      delete res;
      break;
    }

    TString src=Form("%s",objs->GetString().Data());
    outputFile << src.Data()<< endl;
  }
  outputFile.close();
  return;
}
Example #2
0
/*ARGSUSED*/
static int
gather_map(void *ignored, const prmap_t *map, const char *objname)
{
    mapdata_t *data;

    /* Skip mappings which are outside the range specified by -A */
    if (!address_in_range(map->pr_vaddr,
                          map->pr_vaddr + map->pr_size, map->pr_pagesize))
        return (0);

    data = nextmap();
    data->md_map = *map;
    if (data->md_objname != NULL)
        free(data->md_objname);
    data->md_objname = objname ? strdup(objname) : NULL;

    return (0);
}
Example #3
0
/*ARGSUSED*/
static int
gather_xmap(void *ignored, const prxmap_t *xmap, const char *objname,
            int last, int doswap)
{
    mapdata_t *data;

    /* Skip mappings which are outside the range specified by -A */
    if (!address_in_range(xmap->pr_vaddr,
                          xmap->pr_vaddr + xmap->pr_size, xmap->pr_pagesize))
        return (0);

    data = nextmap();
    data->md_xmap = *xmap;
    if (data->md_objname != NULL)
        free(data->md_objname);
    data->md_objname = objname ? strdup(objname) : NULL;
    data->md_last = last;
    data->md_doswap = doswap;

    return (0);
}