コード例 #1
0
ファイル: LuaList.cpp プロジェクト: hunbernd/Lua4RS
void LuaList::rename(const QString& oldName, const QString& newName)
{
    QString luaFileNameOld, luaFileNameNew, settingsFileNameOld, settingsFileNameNew;
    getFileNames(oldName, luaFileNameOld, settingsFileNameOld);
    getFileNames(newName, luaFileNameNew, settingsFileNameNew);

    QFile fCode(luaFileNameOld);
    QFile fSettings(settingsFileNameOld);

    if(fCode.exists())
        fCode.rename(luaFileNameNew);
    if(fSettings.exists())
        fSettings.rename(settingsFileNameNew);
}
コード例 #2
0
StringSet SourceHighlightUtils::getOutLangFileNames(const std::string _path) {
    string path = _path;
    if (path == "")
        path = Settings::retrieveDataDir();

    return getFileNames(path, "outlang");
}
コード例 #3
0
  void TOPPASOutputFileListVertex::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
  {
    QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    if (isSelected())
    {
      pen.setWidth(2);
      painter->setBrush(brush_color_.darker(130));
      pen.setColor(Qt::darkBlue);
    }
    else
    {
      painter->setBrush(brush_color_);
    }
    painter->setPen(pen);

    QPainterPath path;
    path.addRoundRect(-70.0, -40.0, 140.0, 80.0, 20, 20);
    painter->drawPath(path);

    pen.setColor(pen_color_);
    painter->setPen(pen);
    QString text =  QString::number(files_written_) + "/"
                   + QString::number(files_total_) + " output file" + (files_total_ == 1 ? "" : "s");
    QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
    painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);

    // display file type(s)
    Map<QString, Size> suffices;
    foreach(QString fn, getFileNames())
    {
      QStringList l = QFileInfo(fn).completeSuffix().split('.');
      QString suf = ((l.size() > 1 && l[l.size() - 2].size() <= 4) ? l[l.size() - 2] + "." : QString()) + l.back(); // take up to two dots as suffix (the first only if its <=4 chars, e.g. we want ".prot.xml" or ".tar.gz", but not "stupid.filename.with.longdots.mzML")
      ++suffices[suf];
    }
コード例 #4
0
TemporaryColumnMapper::TemporaryColumnMapper(const char * _path, size_t _tableId, size_t _columnId, aq::ColumnType _itemType, size_t _itemSize, size_t _packetSize)
  : 
  nbRemap(0),
  path(_path),
  tableId(_tableId),
  columnId(_columnId),
  itemSize(_itemSize),
  itemType(_itemType),
  packetSize(_packetSize),
  currentPacket(0)
{
  char prefix[128];
  char type_str[128];
  switch (itemType)
  {
  case COL_TYPE_VARCHAR: strcpy(type_str, "CHA"); break;
	case COL_TYPE_INT: strcpy(type_str, "INT"); break;
	case COL_TYPE_DOUBLE: strcpy(type_str, "DOU"); break;
	case COL_TYPE_BIG_INT:
	case COL_TYPE_DATE:
    strcpy(type_str, "LON"); 
    break;
  }
  sprintf( prefix, "B001TMP%.4uC%.4u%s%.4uP", tableId, columnId, type_str, itemSize );
	getFileNames(path.c_str(), this->temporaryFiles, prefix );
  assert(!this->temporaryFiles.empty());
	this->tmpMapper.reset(new aq::FileMapper(this->temporaryFiles[this->currentPacket].c_str()));
  tmpMappers.resize(temporaryFiles.size());
}
コード例 #5
0
void CMainFrame::OnFileOpen(int id) {
  TextView   *view = getActiveTextView();
  if(view == NULL) {
    showWarning(_T("No active view"));
    return;
  }
  CFileDialog dlg(TRUE);
  dlg.m_ofn.lpstrFilter  = getFileDialogExtension().cstr();
  dlg.m_ofn.lpstrTitle   = _T("Open files");
  dlg.m_ofn.nFilterIndex = getOptions().m_defaultExtensionIndex;
  dlg.m_ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST;
  TCHAR fileNames[1024];
  fileNames[0]           = 0;
  dlg.m_ofn.lpstrFile    = fileNames;
  dlg.m_ofn.nMaxFile     = ARRAYSIZE(fileNames);

  if((dlg.DoModal() != IDOK) || (_tcsclen(fileNames) == 0)) {
    return;
  }
  getOptions().m_defaultExtensionIndex = dlg.m_ofn.nFilterIndex;

  TCHAR *files[3];
  getFileNames(files,fileNames);

  CWinDiffDoc *doc = view->getDocument();

  if(_tcsclen(files[1]) == 0) { // only one selected
    doc->setDoc(id, DIFFDOC_FILE, files[0]);
  } else {
    const String f1 = FileNameSplitter::getChildName(files[0],files[1]);
    const String f2 = FileNameSplitter::getChildName(files[0],files[2]);
    doc->setDocs(f1, f2);
  }
  Invalidate(FALSE);
}
コード例 #6
0
StringSet SourceHighlightUtils::getCssStyleFileNames(const std::string _path) {
    string path = _path;
    if (path == "")
        path = Settings::retrieveDataDir();

    return getFileNames(path, "css");
}
コード例 #7
0
  void TOPPASInputFileListVertex::showFilesDialog()
  {
    TOPPASInputFilesDialog tifd(getFileNames(), cwd_);
    if (tifd.exec())
    {
      QStringList updated_filelist;
      tifd.getFilenames(updated_filelist);
      if (getFileNames() != updated_filelist)
      { // files were changed
        setFilenames(updated_filelist); // to correct filenames (separators etc)
        qobject_cast<TOPPASScene *>(scene())->updateEdgeColors();

        // update cwd
        cwd_ = tifd.getCWD();

        emit parameterChanged(true); // aborts the pipeline (if running) and resets downstream nodes
      }
    }
  }
コード例 #8
0
//remove files
void removeFiles(){

	 vector<string> fileNames;
	 getFileNames(&fileNames);

	 int size = fileNames.size();

	 for(int i=0; i<size; i++){
		 if(remove(fileNames[i].c_str())) {
			 printf("Could not delete the file");
		 }
	 }
}
コード例 #9
0
ファイル: LuaList.cpp プロジェクト: hunbernd/Lua4RS
bool LuaList::save(LuaContainer* container)
{
    if(_filePath == "")
        return false;

    QString luaFileName, settingsFileName;
    getFileNames(container->getName(), luaFileName, settingsFileName);

    // save code
    {
        std::ofstream file;
        file.open(luaFileName.toLocal8Bit().data(), std::ios::trunc);
        if(!file.is_open())
        {
            std::cerr << "[Lua] can't open file " << luaFileName.toStdString() << std::endl;
            return false;
        }

        std::string code;
#ifdef _WIN32
        code = container->getCode().toLocal8Bit().constData();
#else
        code = container->getCode().toUtf8().constData();
#endif
        // rest = code
        file << code;

        file.flush();
        file.close();
    }

    // save config
    {
        QSettings settings(settingsFileName, QSettings::IniFormat);        
        if(!settings.isWritable())
        {
            std::cerr << "[Lua] no write access for settings file " << settingsFileName.toStdString() << " -> aborting (code was saved)" << std::endl;
            return false;
        }
        settings.clear();
        container->getSettings(settings);
    }

    return true;
}
コード例 #10
0
ファイル: lcd.c プロジェクト: franbienjan/NDSGthesis
int chy(){
    
	// get contents of file agent
    getFileNames();
    
	// rabin fingerprinting, SHA-1, extreme binning
    rabinChunking();
    
    // compare chunks
    //comparePrints();
    
    // remake new files from chunks
    //remakeFiles();
    
	
	return 0;
    
}
コード例 #11
0
ファイル: trainsamplepage.cpp プロジェクト: KDE/simon
bool TrainSamplePage::serializeToStorage(QSettings& ini, const QString& directory) const
{
  bool succ = true;

  //copy files to target directory
  QStringList fileNames = getFileNames();
  foreach (const QString& fileName, fileNames) {
    QString onlyName = fileName.mid(qMax(fileName.lastIndexOf("/"), fileName.lastIndexOf(QDir::separator())));
    if (!QFile::copy(fileName, directory+QDir::separator()+onlyName)) {
      kDebug() << "could not copy " << fileName << " to " << directory+QDir::separator()+onlyName;
      fileNames.removeAll(fileName);

      succ = false;
    }
    else {
      if (!QFile::remove(fileName))
        kWarning() << "Could not remove original input file!";
    }
  }
コード例 #12
0
ファイル: stream.c プロジェクト: ChappedSky/hancock
static void generalStreamReg(HRSstream_t s, void *tf)
{
  s->type = HRS_GENERALSTREAM;

  s->gs = (generalStream_s *) HRSmalloc(sizeof(generalStream_s), 
				       "generalStreamReg");
  s->bs = NULL;
  s->ms = NULL;
  
  if (strcmp(s->streamName, "sfstdin") == 0 || 
      (strcmp(s->streamName, "stdin") == 0)) {
    s->gs->numFileNames = 0;
    s->gs->numFilesinStream = 1;  /* count standard in stream as one file */
    s->gs->fileNames = NULL;
    s->gs->sio = 1;  /* standard in stream */
  }
  else if (isDir(s->streamName)) {
    s->gs->numFileNames = countFiles(s->streamName);
    s->gs->fileNames = (char **) HRSmalloc(sizeof(char *)*s->gs->numFileNames,
					  "generalStreamReg");
    getFileNames(s->streamName, s->gs->fileNames, 0);
    s->gs->numFilesinStream = s->gs->numFileNames;
    s->gs->sio = 0;
  }
  else { /* single file stream */
    s->gs->numFileNames = 1;
    s->gs->fileNames = (char **) HRSmalloc(sizeof(char *)*s->gs->numFileNames,
				    "generalStreamReg");
    s->gs->fileNames[0] = (char *) HRSmalloc(strlen(s->streamName)+1, 
					     "generalStreamReg");

    strcpy(s->gs->fileNames[0], s->streamName);
    checkStreamFile(s->gs->fileNames[0], 0);
    s->gs->numFilesinStream = s->gs->numFileNames;
    s->gs->sio = 0;
  }
   
  s->gs->count = 0;
  s->gs->translate = (int (*)(char, void *, Sfio_t *, char *))tf;
  s->gs->filter = NULL;

}
コード例 #13
0
ファイル: stream.c プロジェクト: ChappedSky/hancock
static void binaryStreamReg(HRSstream_t s,int physicalSize, void *tf)
{
  s->type = HRS_BINARYSTREAM;

  s->bs = (binaryStream_s *) HRSmalloc(sizeof(binaryStream_s), 
				      "binaryStreamReg");
  s->gs = NULL;
  s->ms = NULL;

  s->bs->physicalSize = physicalSize;
  s->bs->temp = (char *) HRSmalloc(physicalSize, "binaryStreamReg");

  if (strcmp(s->streamName, "sfstdin") == 0 || 
      (strcmp(s->streamName, "stdin") == 0)) {
    s->bs->numFileNames = 0;
    s->bs->numFilesinStream = 1;  /* count standard in stream as one file */
    s->bs->fileNames = NULL;
    s->bs->sio = 1;  /* standard in stream */
  }
  else if (isDir(s->streamName)) {
    s->bs->numFileNames = countFiles(s->streamName);
    s->bs->fileNames = (char **) HRSmalloc(sizeof(char *)*s->bs->numFileNames,
				    "binaryStreamReg");
    getFileNames(s->streamName, s->bs->fileNames, physicalSize);
    s->bs->numFilesinStream = s->bs->numFileNames;
    s->bs->sio = 0;
  }
  else { /* single file stream */
    s->bs->numFileNames = 1;
    s->bs->fileNames = (char **) HRSmalloc(sizeof(char *), "binaryStreamReg");
    s->bs->fileNames[0] = (char *) HRSmalloc(strlen(s->streamName)+1, 
					    "binaryStreamReg");
    strcpy(s->bs->fileNames[0], s->streamName);
    checkStreamFile(s->bs->fileNames[0], physicalSize);
    s->bs->numFilesinStream = s->bs->numFileNames;
    s->bs->sio = 0;
  }
   
  s->bs->count = 0;
  s->bs->translate = (int (*)(char, void *, char *, char *))tf;
  s->bs->filter = NULL;
}
コード例 #14
0
void CMakeAviDlg::OnFileAddfFiles() {
  CFileDialog dlg(TRUE);
  dlg.m_ofn.lpstrFilter  = fileDialogExtensions;
  dlg.m_ofn.lpstrTitle   = _T("Add files");
  dlg.m_ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST;
#define NAMEBUFFERLENGTH 500000
  TCHAR *nameBuffer = new TCHAR[NAMEBUFFERLENGTH];
  nameBuffer[0] = 0;
  dlg.m_ofn.lpstrFile = nameBuffer;
  dlg.m_ofn.nMaxFile  = NAMEBUFFERLENGTH;

  if(dlg.DoModal() == IDOK) {
    m_nameArray = getFileNames(nameBuffer);
    m_nameArray.sort(stringCmp);
    m_nameList.DeleteAllItems();
    for(size_t i = 0; i < m_nameArray.size(); i++) {
      addData(m_nameList, (int)i, 0, m_nameArray[i], true);
    }
    Invalidate();
  }
  delete[] nameBuffer;
}
コード例 #15
0
KoResourceLoaderThread::KoResourceLoaderThread(KoResourceServerBase * server)
    : QThread()
    , m_server(server)
{
    m_fileNames = getFileNames(m_server->extensions());
}
コード例 #16
0
ファイル: interface.c プロジェクト: 713/project
Args *getArgs(int argc, char *argv[]){
  Args *args;
  //	char **r;
  char c;
  int arg;
  //	int numberOfFiles;
  char list[256] = {0}; // options are not yet set

  args = (Args *)emalloc(sizeof(Args));

  args->i = NULL;
  args->j = NULL;
  args->o = NULL;
  args->h = 0;
  args->p = 0;  
  args->e = 0;
  args->d = NULL;
  args->n = NAMELENGTH;
  args->D = DEFAULT_D;
  args->w = DEFAULT_W;
  args->c = 0; 
  args->q = 10000;
  args->W = NULL;
  args->P = 1-DEFAULT_P;
  args->v = 0;
  arg = 1;
  args->m = DEFAULT_M;
  args->t = 0;
  args->r = 0;
  args->s = 0;
  args->f = -1;

  // if none of the options is set as an argument, then take o1
  args->o1 = 0;
  args->o2 = 0;
  args->I = NULL;
  args->M = 0; // default min window sum to be considered relevant

  while(arg < argc){
    c = argv[arg][1];
    switch (c){
    case 'i':                           /* query file; if the option -d is included */ 
      checkNullPointer(c, argv[arg]);
      //args->i = argv[arg];            /* then search for the query file: (1) in the program's dir (2) in the directory specified with -d*/
      // read one or more query files specified with an option -i
      getFileNames(argc, argv, list, c, &args->i, &args->queryFileNumber, &arg);
      break;
				      
    case 'j':                           /* subject files */
      /* check that -d and -j option are used mutually exclusive! */
      if (args->d) {
	eprintf("Options -d and -j are mutually exclusive");
      }
      else {
	getFileNames(argc, argv, list, c, &args->j, &args->subjectFileNumber, &arg);
	break;
      }

    case 'd':                           /* directory where the subject files are saved and possibly the query file */
      if (args->j) {
	eprintf("Options -d and -j are mutually exclusive");
      }
      else {
	args->d = argv[++arg];
	checkNullPointer(c, args->d);
	checkMultipleArgDef(list, c);
	break;
      }

    case 'o':                           /* output file */
      checkNullPointer(c, argv[++arg]);
      args->o = argv[arg];
      checkMultipleArgDef(list, c);
      break;

    case 'n':                            /* number of characters from header line printed */
      checkNullPointer(c, argv[++arg]);
      args->n = atoi(argv[arg]);
      if(args->n < 0) {
	args->n = INT_MAX;
      }
      checkMultipleArgDef(list, c);
      break;

    case 'D':                            /* maximum depth of suffix tree */
      args->D = atoi(argv[++arg]);
      checkNullPointer(c, argv[arg]);
      checkMultipleArgDef(list, c);
      break;
				
    case 'w':                             /* window width and window increment */
      checkNullPointer(c, argv[++arg]);
      args->w = atoi(argv[arg]);
      checkMultipleArgDef(list, c);
      break;
			
    case 'c':                             /* sliding window increment */
      checkNullPointer(c, argv[++arg]);
      args->c = atoi(argv[arg]);
      checkMultipleArgDef(list, c);
      break;

    case 'v':                           /* print program version test */
      args->v = 1;
      break;
      
    case 'h':                           /* print help */
      args->h = 1;
      break;

    case 'W':                            /* output file where window analysis for all subjects are printed */
      args->W = argv[++arg];
      checkNullPointer(c, args->W);
      checkMultipleArgDef(list, c);
      break;

    case 'P':                            /* fraction of random shustrings excluded from analysis */
      args->P = atof(argv[++arg]);
      if (args->P < 0) {
	args->P = 0;
      }
      else if(args->P > 1) {
	args->P = 1;
      }
      args->P = 1 - args->P;
      break;

    case 'q':                            /* fast search - size of mini list*/
      args->q = atol(argv[++arg]);
      if (args->q < 0) {
	args->q = 1000;
      }
      break;

    case 'm':                            /* multiplier for maxshulen by chance alone -- used for defining significant intervals */
      args->m = atol(argv[++arg]);
      if (args->m < 0) {
	args->m = DEFAULT_M;
      }
      break;

    case 't':                           /* print run-time information */
      args->t = 1;
      break;

    case 'r':                           /* print runner(s)-up information */
      args->r = 1;
      break;

    case 'f':                            /* minimal length of recombination fragment */
      args->f = atoi(argv[++arg]);
      //if (args->f < 0) {
      //	args->f = (int)args->w;
      //}
      break;

    case 'o1':                           /* each annotation has the same subject set over all windows within annotation */
      args->o1 = 1;
      break;

    case 'o2':                           /* subject set of an annotation is a subset of all windows within annotation */
      args->o2 = 1;
      break;


    case 'M':                           /* minimal sum: max shulen by chance alone x window size */
      args->M = 1;
      break;

    case 'I':                            /* name of input file that contains list of intervals; used for windows analysis based on precomputed intervals */
      args->I = argv[++arg];
      checkNullPointer(c, args->I);
      checkMultipleArgDef(list, c);
      break;

    default:
      printf("# unknown argument: %c\n", c);
      args->e = 1;
      return args;
    } // end switch
		
    arg++;  
  } // end while

  // allowed stdin?
  // if (!args->i) {
  //   printf("ERROR[gt]: Query file must be specified using -i option!\n");
  //   args->e = 1;
  //}
  if (args->c == 0) {
    args->c = (int)((float)args->w/10. + 0.5);
  }
  if (args->f < 0) {
    //args->f = (int)args->c;
    args->f = (int)((float)args->w / 4. + 0.5);
  }

  if (args->w < args->c) {
    printf("ERROR: Sliding window increment is greater than window size\n");
    args->e = 1;
  }

  if (!args->o1 && !args->o2) {
    args->o1 = 1; // when none of the options is set, set o1 as default
  }
  else if (args->o1 && args->o2) {
    printf("ERROR: Options 1 and 2 are mutually exclusive\n");
    args->e = 1;
  }

  if (args->o && args->I) {
    printf("Interval analysis exists, so it won't be computed again (-o will be ignored)\n");
  }

  return args;
}
コード例 #17
0
ファイル: trainsamplepage.cpp プロジェクト: KDE/simon
bool TrainSamplePage::cleanUp()
{
  bool succ=true;
  if (recorder->hasRecordingReady()) {
    succ = recorder->deleteAll();
    if (!succ)
      KMessageBox::error(this, i18nc("%1 is file names", "Could not remove samples \"%1\".", getFileNames().join("\", \"")));
  }

  return succ;
}
コード例 #18
0
ファイル: FileFragment.hpp プロジェクト: srl147/libmaus
			static void removeFiles(std::vector<FileFragment> const & V)
			{
			        std::vector<std::string> S = getFileNames(V);
			        for ( uint64_t i = 0; i < S.size(); ++i )
			                remove ( S[i].c_str() );
			}
コード例 #19
0
ファイル: LuaList.cpp プロジェクト: hunbernd/Lua4RS
bool LuaList::load(const QString& name, LuaContainer* container, bool ignoreNoSettingsFile)
{
    if(_filePath == "")
        return false;

    // set name
    container->setName(name);

    QString luaFileName, settingsFileName;
    getFileNames(name, luaFileName, settingsFileName);

    // load code
    {
        // check whether file exists
        if(!QFile::exists(luaFileName))
        {
			std::cerr << "[Lua] can't find Lua file, checking templates" << luaFileName.toStdString() << std::endl;
			QString templatename(_templateFilePath + name);
			if(QFile::exists(templatename))
			{
				if(!QFile::copy(templatename, luaFileName))
				{
					return false;
				}
			}else{
				std::cerr << "[Lua] can't find Lua file in templates" << templatename.toStdString() << std::endl;
				return false;
			}
        }

        std::ifstream file;
        file.open(luaFileName.toLocal8Bit().data(), std::ios::in);
        if(!file.good() || !file.is_open())
        {
            std::cerr << "[Lua] can't open file " << luaFileName.toStdString() << std::endl;
            return false;
        }

        std::string line, c = "";
        while(!file.eof())
        {
            std::getline(file, line);
            c += line;

            // don't add \n at the end of the file
            if(!file.eof())
                c += '\n';
        }
        container->setCode(c);

        file.close();
    }

    // load config
    {
        // check whether file exists
        if(!QFile::exists(settingsFileName))
        {
            if(ignoreNoSettingsFile)
            {
                std::cerr << "[Lua] can't find settings file " << settingsFileName.toStdString() << " -> continuing" << std::endl;
                return true;
            } else
            {
                std::cerr << "[Lua] can't find settings file " << settingsFileName.toStdString() << " -> aborting" << std::endl;
                return false;
            }
        }

        QSettings settings(settingsFileName, QSettings::IniFormat);
        container->loadSettings(settings);
    }
    return true;
}