Exemple #1
0
Boolean shelf_push(int i, Boolean absolute, Boolean pushdir)
{
  FilePtr file = dirFile(shelfdir, i);
  String action;
  char path1[MAXPATHLEN+1], path2[MAXPATHLEN+1];

  root_modified = cur_modified = shelf_modified = cur_changed = False;
  if (file)
    if (!((action = push_action(fileType(file))) && *action) &&
	S_ISDIR(fileStats(file)->st_mode)) {
      return
	cur_chdir(resolve(path1, pathname(path2, dirName(shelfdir),
					  fileName(file))));
    } else {
      Boolean ret =
	filePush(shelfdir, i,
		 (pushdir && (fileStats(file)->st_mode &
			      (S_IXUSR | S_IXGRP | S_IXOTH)))?
		 dirName(curdir):NULL, absolute, True);
      update();
      return ret;
    }
  else
    return False;
}
Exemple #2
0
void CaViewerScanner::scanFolders(const QStringList& slFolder)
{
    for(int countFolder = 0; countFolder < slFolder.size(); ++countFolder)
    {
        const QString sCurFolder = slFolder.at(countFolder);
        QDir dirFolder(sCurFolder);
        dirFolder.setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
        if(dirFolder.exists())
        {
            scanFolders(dirFolder.entryList());

            QDir dirFile(sCurFolder);
            dirFile.setFilter(QDir::Files);
            const QFileInfoList fileList = dirFile.entryInfoList();
            for(int countFile = 0; countFile < fileList.size(); ++countFile)
            {
                const QFileInfo info = fileList.at(countFile);
                const QString sFileName = info.fileName();
                const QString sPath = info.absolutePath() + QChar('/');

                QString sBaseName;
                const QStringList slSeries = getImageSeries(sPath, sFileName, sBaseName);
                const QString sMaster = slSeries.first();
                const QString sMasterHash = getHash(sPath + sMaster);
                if(registerMasterImage(sPath, sMaster))
                {
                    for(int countSeries = 1; countSeries < slSeries.size(); ++countSeries)
                        registerChainImage(sMasterHash, sPath, slSeries.at(countSeries));
                }
            }

        }
    }
}
Exemple #3
0
void ViStatistician::addDir(QString dirName)
{
	QDir dirFile("/home/visore/Visore Projects/Files/" + dirName);
	if(!dirFile.exists())
	{
		cout << "Directory does not exist: " << dirFile.absolutePath().toLatin1().data() << endl;
		return;
	}

	QDir dirResult("/home/visore/Visore Projects/Results/" + dirName);
	if(!dirResult.exists()) dirResult.mkpath(dirResult.absolutePath());

	QDir dir(dirFile.absolutePath());
	QStringList files = dir.entryList(QDir::Files);
	for(int j = 0; j < files.size(); ++j)
	{
		mFiles.enqueue(dir.absoluteFilePath(files[j]));
	}

	QString name = "";
	if(mMode == Mean) name = "mean";
	else if(mMode == StandardDeviation) name = "standarddeviation";
	else if(mMode == Pearson) name = "pearson";
	mFile = dirResult.absolutePath() + "/summary" + name + ".txt";
}
Exemple #4
0
void ViNoiseBatcher::addDir(QString dirName)
{
	QDir dirFile("/home/visore/Visore Projects/Files/" + dirName);
	if(!dirFile.exists())
	{
		cout << "Directory does not exist: " << dirFile.absolutePath().toLatin1().data() << endl;
		return;
	}

	QDir dirResult("/home/visore/Visore Projects/Results/" + dirName);
	if(!dirResult.exists()) dirResult.mkpath(dirResult.absolutePath());

	if(SUMMARY)
	{
		QString summary = dirResult.absolutePath() + "/summary.txt";
		if(!mSummaryFiles.contains(summary))
		{
			printFileHeader(summary);
			mSummaryFiles.append(summary);
		}
	}

	QDir dir(dirFile.absolutePath());
	QStringList files = dir.entryList(QDir::Files);
	for(int j = 0; j < files.size(); ++j)
	{
		mFiles.enqueue(dir.absoluteFilePath(files[j]));
		QString id = ViId::generate();
		mResults.enqueue(dirResult.absolutePath() + "/" + mDetector->name() + "_" + id + "_ALL.txt");
		mResults2.enqueue(dirResult.absolutePath() + "/" + mDetector->name() + "_" + id + "_MINIFIED.txt");
	}
}
Exemple #5
0
static Boolean dir_is_drop_target(DirPtr dir, int i)
{
  FilePtr file = dirFile(dir, i);
  String action = drop_action(fileType(file));

  return i == NONE || file &&
    (action && *action ||
     S_ISDIR(fileStats(file)->st_mode) ||
     (fileStats(file)->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)));
}
bool JSONFileLoader::Load(const std::string& szFileName, json_spirit::mObject& tData, const std::string& szSubDirectory, bool bIsBinary)
{
	bool bSuccess = false;

	if (!szFileName.empty())
	{
		std::string szDirPath = APP_DATA_PATH + "\\";
		if (!szSubDirectory.empty())
		{
			szDirPath += szSubDirectory + "\\";
			boost::filesystem::path newDir(szDirPath);

			if (!boost::filesystem::exists(newDir))
			{
				if (!boost::filesystem::create_directory(newDir))
				{
					bSuccess = false;
				}
			}
		}

		if (!szDirPath.empty())
		{
			std::string szDirFile = szDirPath + szFileName;
			boost::filesystem::path dirFile(szDirFile);
			if (boost::filesystem::exists(dirFile))
			{
				json_spirit::mValue readVal;

				if (!bIsBinary)
				{	
					std::ifstream jsonInFile(szDirFile);
					json_spirit::read(jsonInFile, readVal);
					jsonInFile.close();
				}
				else
				{
					std::ifstream jsonInFile(szDirFile, std::ios::binary);
					json_spirit::read(jsonInFile, readVal);
					jsonInFile.close();
				}

				tData["DATA"] = readVal;
				bSuccess = true;
			}
		}
	}

	return bSuccess;
}
bool JSONFileLoader::Save(const std::string& szFileName, json_spirit::mObject tData, const std::string& szSubDirectory, bool bOverwrite, bool bIsBinary)
{
	bool bSuccess = false;

	if (!szFileName.empty())
	{
		std::string szDirPath = APP_DATA_PATH + "\\";
		if (!szSubDirectory.empty())
		{
			szDirPath += szSubDirectory + "\\";
			boost::filesystem::path newDir(szDirPath);

			if (!boost::filesystem::exists(newDir))
			{
				if (!boost::filesystem::create_directory(newDir))
				{
					bSuccess = false;
				}
			}
		}

		if (!szDirPath.empty())
		{
			std::string szDirFile = szDirPath + szFileName;
			boost::filesystem::path dirFile(szDirFile);
			if ((!boost::filesystem::exists(dirFile)) || (bOverwrite && boost::filesystem::is_regular_file(dirFile)))
			{
				if (!bIsBinary)
				{
					std::ofstream jsonFile(szDirFile);
					json_spirit::write(tData, jsonFile, json_spirit::Output_options::pretty_print);
					jsonFile.close();
					
				}
				else
				{
					std::ofstream jsonBinaryFile(szDirFile, std::ios::binary);
					json_spirit::write(tData, jsonBinaryFile, json_spirit::Output_options::none);
					jsonBinaryFile.close();
				}

				bSuccess = true;
			}
		}
	}

	return bSuccess;
}
void FindAllAdornedVariants(const std::wstring& aSearchNameWild, const std::wstring& aSearchPath, std::list<std::wstring>& aAdornedFileNamesFound, const DrivesMap& aDriveMap)
{
	DrivesMap::const_iterator it = aDriveMap.begin();
	DrivesMap::const_iterator end = aDriveMap.end();

	for ( ; it != end ; ++it)
	{
		// drive to search on
		int disk = tolower(it->first);
		std::wstring drive = L"$:";
		drive[0] = disk;

		std::wstring searchPath(aSearchPath);

		// actual readable directory
		std::wstring localDir = it->second->iDir;

		// using ROM/ROFS logs for the z drive, searching for adorned variants is handled later.
		if (disk == 'z' && localDir.empty())
			continue;

		// convert to the local path and see if the file exists on the drive
		ConvertToLocalPath( searchPath, localDir );

		// search this directory 
		std::list<std::wstring> dirContents;
		GetDirContents(searchPath, dirContents);

		std::list<std::wstring>::iterator curr = dirContents.begin();
		std::list<std::wstring>::iterator end = dirContents.end();
		while (curr != end)
		{
			std::wstring dirFile(*curr);

			if (StringUtils::WildcardCompare(aSearchNameWild,dirFile))
			{
				// found an adorned file, add to the list of adorned names found
				std::wstringstream foundFile;
				foundFile << drive << aSearchPath << dirFile;
				aAdornedFileNamesFound.push_back(foundFile.str());
			}

			++curr;
		}
	}
}
Exemple #9
0
Boolean cur_drop(int i, int op, SelPtr sel, Boolean absolute,
		 Boolean dirtarget)
{
  Boolean ret;
  FilePtr file = dirFile(curdir, i);
  String action;
  char path[MAXPATHLEN+1];

  if (i != NONE)
    if (!((action = drop_action(fileType(file))) && *action) &&
	S_ISDIR(fileStats(file)->st_mode))
      ret = fileMov(op)(sel, pathname(path, dirName(curdir),
				      fileName(file)), absolute);
    else
      ret = fileDrop(curdir, i, sel, absolute, dirtarget, False);
  else
    ret = fileMov(op)(sel, dirName(curdir), absolute);
  update();
  return ret;
}
Exemple #10
0
Boolean cur_push(int i, Boolean absolute, Boolean pushdir)
{
  FilePtr file = dirFile(curdir, i);
  String action;
  char path1[MAXPATHLEN+1], path2[MAXPATHLEN+1];

  root_modified = cur_modified = shelf_modified = cur_changed = False;
  if (file)
    if (!((action = push_action(fileType(file))) && *action) &&
	S_ISDIR(fileStats(file)->st_mode)) {
      return
	cur_chdir(shortestpath(path1, pathname(path2, dirName(curdir),
					       fileName(file))));
    } else {
      Boolean ret = filePush(curdir, i, NULL, absolute, False);
      update();
      return ret;
    }
  else
    return False;
}
DiskSampleRecorder::DiskSampleRecorder ( const char* recordDir, const int* inChannels, const int inChannelsCount, float duration )
							:	AudioSampleRecorder( 0, 0, inChannelsCount, inChannelsCount),
								mchaRecordPlayer( MchaRecordPlayer::getInstance() ),
								dataWriter(NULL),
								outputDir(String::empty),
								bytesSaved(0),
								endBuffer(0),
								samplingRate(-1.0f), 
								bufferSize(-1),
								bitDepth(-1)
{
	mchaRecordPlayer->dbgOut( "DiskSampleRecorder created" );	
	mchaRecordPlayer->dbgOut( "\tRecorder input channels:\t" + String(processorInputs) );
	mchaRecordPlayer->dbgOut( "\tRecorder output channels:\t" + String(processorOutputs) );		

	int inChans = -1;
	int outChans = -1;
	if ( !mchaRecordPlayer->getDeviceSettings().getSettings(samplingRate, bufferSize, bitDepth, inChans, outChans) )
	{
		mchaRecordPlayer->logError( L"\tDiskSampleRecorder::DiskSampleRecorder failed: unable to get device settings");
		mchaRecordPlayer->dbgOut( mchaRecordPlayer->getDeviceSettings().getErrorString() );
		return;
	}

	/* Create a copy of output directory */
	outputDir = String(recordDir);
	if ( !outputDir.endsWith(File::separatorString))
		outputDir += File::separatorString;

	/* Check if the directory exists and create it if required */
	File dirFile(outputDir);
	if (outputDir.isNotEmpty())
	{
		if ( !dirFile.isDirectory() )	/* either not a directory or does not exist */
		{
			if ( !dirFile.createDirectory() ) /* try create this directory */
			{
				mchaRecordPlayer->logError( L"\tOutput directory is invalid:\t" + outputDir );
				return;
			}
			else
			{
				mchaRecordPlayer->dbgOut( "\tDirectory created:\t" + outputDir );		
			}
		}
		else
		{
			mchaRecordPlayer->dbgOut("\tOutput directory:\t" + outputDir );		
		}
	}



	/* Check the number of input channels */
	if (processorInputs < 1)
	{
		mchaRecordPlayer->logError( L"\tWrong number of input channels (" + String(processorInputs) + ")" );
		return;	
	}

	/* Check the input channels array */
	if (inChannels == NULL)
	{
		mchaRecordPlayer->logError( L"\tInput channels are not specified" );
		return;
	}
	
	/* map device channels to data channels */
	channelsMap.insertArray(0, inChannels, inChannelsCount);

	/* Calculate the maximum available record length */
	int64	freeDiskBytes = dirFile.getBytesFreeOnVolume();
	mchaRecordPlayer->dbgOut( "\tFree disk space, b:\t" + String(freeDiskBytes) );

	/* Bytes per sample for one channel */
	int		bytesPerSample = (int) ceil( (double) bitDepth / 8); 
	
	/* Bytes per one buffer for one channel */
	int		bufferInBytes = bufferSize * bytesPerSample;

	/* The maximum number of buffers available for recording */
	int64	maxNumberOfBuffers =	( freeDiskBytes  - processorOutputs * MAX_FORMAT_HEADER ) / 
									( bufferInBytes*processorOutputs)/2;

	if (maxNumberOfBuffers < 1)
	{
		mchaRecordPlayer->logError( L"\tInsufficient disk space:\t" + String(freeDiskBytes) + " bytes free on drive " + dirFile.getVolumeLabel() );
		return ;
	}

	/* Maximum duration */
	double maxRecordDuration = maxNumberOfBuffers * bufferSize / samplingRate;
	RelativeTime tm( maxRecordDuration );
	mchaRecordPlayer->dbgOut( "\tMaximum available record duration:\t" + tm.getDescription() );


	if (duration < 0 )
	{
		endBuffer = maxNumberOfBuffers;
	}
	else
	{
		endBuffer = (int64) ceil( duration*samplingRate / bufferSize );
		if (endBuffer > maxNumberOfBuffers)
		{
			mchaRecordPlayer->logError( L"WARNING: Not enough disk space to save the files. Record duration has been decreased to " + 
											String(endBuffer*bufferSize/samplingRate) + " s." );
			endBuffer = maxNumberOfBuffers;
		}
	}
	
	/* Current record length */
	dataLength = endBuffer * bufferSize;
	double currentDuration =  dataLength / samplingRate;
	RelativeTime rectm(currentDuration);
	mchaRecordPlayer->dbgOut( "\tRecord duration:\t" + rectm.getDescription() );

	/* Reserve disk space for final audio files */
	int64 lengthInBytes = endBuffer * bufferSize * bytesPerSample + MAX_FORMAT_HEADER;
	if (!reserveDiskSpace(outputDir, lengthInBytes))
	{
		return ;
	}
	
	return ;

}
 FileInfo RunManager_Util::dirFile(const openstudio::path &p)
 {
   return dirFile(QFileInfo(toQString(p)));
 }
PDB_Country::PDB_Country(QWidget *parent) : QWidget(parent) {
  QLabel *l = new QLabel(i18n("Select the location where you plan to use this\n"
			    "account from the list below. If your country or\n"
			    "location is not listed, you have to create the\n"
			    "account with the normal, dialog based setup.\n\n"
			    "If you click \"Cancel\", the dialog based setup\n"
			    "will start."),
		       this);
  QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
  tl->addWidget(l);

  QHBoxLayout *l1 = new QHBoxLayout;
  tl->addLayout(l1);
  l1->addStretch(1);

  lb = new QListBox(this);
  connect(lb, SIGNAL(highlighted(int)),
	  this, SLOT(selectionChanged(int)));
  lb->setMinimumSize(220, 100);
  l1->addWidget(lb, 2);
  l1->addStretch(1);

  list = new QStringList;

  // fill the listbox
  // set up filter
  QDir d(KGlobal::dirs()->findDirs("appdata", "Provider").first());
  d.setFilter(QDir::Dirs);
  d.setSorting(QDir::Name);

  // read the list of files
  const QFileInfoList *flist = d.entryInfoList();
  if(flist) {
    QFileInfoListIterator it( *flist );
    QFileInfo *fi;
    // traverse the flist and insert into a map for sorting
    QMap<QString, QString> countries;
    for(; (fi = it.current()) != 0; ++it) {
      if(fi->fileName() != "." && fi->fileName() != "..") {
        QString dirFile(fi->absFilePath()+"/.directory");
        QString entryName;
        if(QFile::exists(dirFile)){
          KSimpleConfig config(dirFile);
          config.setDesktopGroup();
          entryName = config.readEntry("Name");
        }
        if (entryName.isNull()) entryName = fi->fileName();
	countries.insert(entryName, fi->fileName());
      }
    }
    // insert sorted entries into list box and string list
    QMap<QString, QString>::const_iterator mit = countries.begin();
    QMap<QString, QString>::const_iterator mend = countries.end();
    while(mit != mend) {
        lb->insertItem(mit.key());
        list->append(*mit);
	++mit;
    }
  }

  tl->activate();
}