Exemplo n.º 1
0
int cmd_ls(const VSTRING& param)
{
    int32_t size = param.size();
    const char* path = (1 == size) ? param.at(0).c_str() : ".";
    char sys_cmd[MAX_CMD_SIZE];
    // just use system tool ls, maybe DIY
    snprintf(sys_cmd, MAX_CMD_SIZE, "ls -FCl %s", path);
    return system(sys_cmd);
}
Exemplo n.º 2
0
int TestCommonUtils::getFilelist(int partNo, int partSize, VUINT32& crcSet, 
      VUINT32& crcSetPerThread, VSTRING& filenameSet, VSTRING& filenameSetPerThread)
{
  // total size less than thread count
  if (partSize == 0)
  {
    partSize = 1; 
  }
  
  int offset = partNo * partSize;
  int end = (offset + partSize) > (int)crcSet.size()? crcSet.size():(offset + partSize); 
  for (; offset < end; offset++)
  {
    crcSetPerThread.push_back(crcSet[offset]);
    filenameSetPerThread.push_back( filenameSet.at(offset).c_str() );
  }

  // the last thread eat the left
  if (partNo == (TestGFactory::_threadCount - 1) )
  {
    for (; offset < (int)crcSet.size(); offset++)
    {
      crcSetPerThread.push_back(crcSet[offset]);
      filenameSetPerThread.push_back( filenameSet.at(offset).c_str() );
    }
  }

  //debug
  /*
  char fileListPerThread[20] = {0};
  sprintf(fileListPerThread, "./read_file_list_%d.txt", partNo);
  FILE *fp = fopen(fileListPerThread, "w");
  VSTRING::iterator it = filenameSetPerThread.begin();
  for (; it != filenameSetPerThread.end(); it++)
  {
     fprintf(fp, "%s\n", it->c_str());
  } 
  fflush(fp);
  fclose(fp);
  */
  return 0;

}