本文整理汇总了C++中QFileInfo类的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo类的具体用法?C++ QFileInfo怎么用?C++ QFileInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QFileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
void ThreadedTracer::run(){
qDebug()<<"loadScan input: "<<latestString;
//QString latestString = getFileString();
// latestString =QString("/data/mat/BRL/DATA_FOR_GROUP/testDataForZhi/ZSeries-06092016-1407-8470/ZSeries-06092016-1407-8470_Cycle00001_Ch1_000001.ome.tif");
// bool isAdaptive = 1;
// int methodChoice = 1;
//LandmarkList inputRootList;
QString fString;
fString = QString("Cycle%1").arg(tileNumber,5,10,QLatin1Char('0'));
qDebug()<<tileNumber;
QList<LandmarkList> newTipsList;
LandmarkList newTargetList;
QFileInfo imageFileInfo = QFileInfo(latestString);
if (imageFileInfo.isReadable()){
Image4DSimple * pNewImage = cb->loadImage(latestString.toLatin1().data());
QDir imageDir = imageFileInfo.dir();
QStringList filterList;
filterList.append(QString("*").append(fString).append("_Ch").append(channel).append("*.tif"));
qDebug()<<"filterlist.first()"<<filterList.first();
imageDir.setNameFilters(filterList);
QStringList fileList = imageDir.entryList();
//use this to id the number of images in the stack (in one channel?!)
V3DLONG x = pNewImage->getXDim();
V3DLONG y = pNewImage->getYDim();
V3DLONG nFrames = fileList.length();
V3DLONG tunits = x*y*nFrames;
unsigned short int * total1dData = new unsigned short int [tunits];
unsigned short int * total1dData_mip= new unsigned short int [x*y];
for(V3DLONG i =0 ; i < x*y; i++)
total1dData_mip[i] = 0;
V3DLONG totalImageIndex = 0;
double p_vmax=0;
qDebug()<<"nFrames = "<<nFrames;
for (int f=0; f<nFrames; f++){
qDebug()<<fileList[f];
Image4DSimple * pNewImage = cb->loadImage(imageDir.absoluteFilePath(fileList[f]).toLatin1().data());
if (pNewImage->valid()){
unsigned short int * data1d = 0;
data1d = new unsigned short int [x*y];
data1d = (unsigned short int*)pNewImage->getRawData();
for (V3DLONG i = 0; i< (x*y); i++)
{
total1dData[totalImageIndex]= data1d[i];
if(data1d[i] > p_vmax) p_vmax = data1d[i];
if(total1dData_mip[i] < data1d[i]) total1dData_mip[i] = data1d[i];
totalImageIndex++;
}
if(data1d) {delete []data1d; data1d = 0;}
}else{
qDebug()<<imageDir.absoluteFilePath(fileList[f])<<" failed!";
}
}
Image4DSimple* total4DImage = new Image4DSimple;
total4DImage->setData((unsigned char*)total1dData, x, y, nFrames, 1, V3D_UINT16);
Image4DSimple* total4DImage_mip = new Image4DSimple;
total4DImage_mip->setData((unsigned char*)total1dData_mip, x, y, 1, 1, V3D_UINT16);
QString swcString = saveDirString;
swcString.append("/x_").append(QString::number((int)tileLocation.x)).append("_y_").append(QString::number((int)tileLocation.y)).append("_").append(imageFileInfo.fileName()).append(fString).append(".swc");
QString scanDataFileString = saveDirString;
scanDataFileString.append("/").append("scanData.txt");
qDebug()<<scanDataFileString;
QFile saveTextFile;
saveTextFile.setFileName(scanDataFileString);// add currentScanFile
if (!saveTextFile.isOpen()){
if (!saveTextFile.open(QIODevice::Text|QIODevice::Append )){
qDebug()<<"unable to save file!";
return;} }
QTextStream outputStream;
outputStream.setDevice(&saveTextFile);
total4DImage->setOriginX(tileLocation.x);
total4DImage->setOriginY(tileLocation.y);
qDebug()<<total4DImage->getOriginX();
outputStream<< (int) total4DImage->getOriginX()<<" "<< (int) total4DImage->getOriginY()<<" "<<swcString<<" "<< (int) x<<" "<< (int) y<<" "<<"\n";
saveTextFile.close();
V3DLONG mysz[4];
mysz[0] = total4DImage->getXDim();
mysz[1] = total4DImage->getYDim();
mysz[2] = total4DImage->getZDim();
mysz[3] = total4DImage->getCDim();
tileLocation.ev_pc1 = (double) total4DImage->getXDim();
tileLocation.ev_pc2 = (double) total4DImage->getYDim();
//.........这里部分代码省略.........
示例2: rootDir
void LoacalFileServer::display(QString* currentPath)
{
//QString currentPath = root;
this->setWindowTitle("LocalFileServer : "+(*currentPath));
QDir rootDir(*currentPath);
QList<QTreeWidgetItem *> itemList;
QStringList tmplist;
tmplist << "*";
QFileInfoList list = rootDir.entryInfoList(tmplist);
for(unsigned int i = 0;i<list.count();i++)
{
QFileInfo tmpFileInfo = list.at(i);
QTreeWidgetItem *item = new QTreeWidgetItem;
if(tmpFileInfo.fileName() == "." || tmpFileInfo.fileName() == "..")
continue;
item->setText(0,tmpFileInfo.fileName());
if(tmpFileInfo.isDir())
{
item->setText(1,QString(""));
}
else
{
item->setText(1,QString::number(tmpFileInfo.size()));
}
item->setText(2,tmpFileInfo.created().toString("MMM dd yyyy"));
item->setText(3,tmpFileInfo.lastModified().toString("MMM dd yyyy"));
QPixmap pixmap(tmpFileInfo.isDir()?"./dir.png":"./file.png");
item->setIcon(0,pixmap);
itemList.push_back(item);
//the path is whether the directory
isDirectory[tmpFileInfo.fileName()] = tmpFileInfo.isDir();
}
fileWidget->addTopLevelItems(itemList);
}
示例3: selectionModel
void ThumbView::handleSelectionChanged(const QItemSelection&)
{
QString info;
QModelIndexList indexesList = selectionModel()->selectedIndexes();
int nSelected = indexesList.size();
QString imageFullPath;
QString statusStr;
infoView->clear();
if (nSelected == 1) {
QString imageFullPath = thumbViewModel->item(indexesList.first().row())->data(FileNameRole).toString();
imageInfoReader.setFileName(imageFullPath);
QString key;
QString val;
QFileInfo imageInfo = QFileInfo(imageFullPath);
infoView->addTitleEntry(tr("General"));
key = tr("File name");
val = imageInfo.fileName();
infoView->addEntry(key, val);
key = tr("Location");
val = imageInfo.path();
infoView->addEntry(key, val);
key = tr("Size");
val = QString::number(imageInfo.size() / 1024.0, 'f', 2) + "K";
infoView->addEntry(key, val);
key = tr("Modified");
val = imageInfo.lastModified().toString(Qt::SystemLocaleShortDate);
infoView->addEntry(key, val);
if (imageInfoReader.size().isValid()) {
key = tr("Format");
val = imageInfoReader.format().toUpper();
infoView->addEntry(key, val);
key = tr("Resolution");
val = QString::number(imageInfoReader.size().width())
+ "x"
+ QString::number(imageInfoReader.size().height());
infoView->addEntry(key, val);
key = tr("Megapixel");
val = QString::number((imageInfoReader.size().width() * imageInfoReader.size().height()) / 1000000.0, 'f', 2);
infoView->addEntry(key, val);
updateExifInfo(imageFullPath);
recentThumb = imageFullPath;
} else {
imageInfoReader.read();
key = tr("Error");
val = imageInfoReader.errorString();
infoView->addEntry(key, val);
}
}
if (imageTags->currentDisplayMode == SelectionTagsDisplay) {
imageTags->showSelectedImagesTags();
}
/* update status bar */
if (!nSelected) {
updateThumbsCount();
return;
} else if (nSelected >= 1) {
statusStr = tr("Selected %1 of%2")
.arg(QString::number(nSelected))
.arg(tr(" %n image(s)", "", thumbViewModel->rowCount()));
}
emit setStatus(statusStr);
}
示例4: QFileInfo
QStringList ScribusQApp::getLang(QString lang)
{
QStringList langs;
// read the locales
if (!lang.isEmpty())
langs.push_back(lang);
//add in user preferences lang, only overridden by lang command line option
QString Pff = QDir::toNativeSeparators(ScPaths::getApplicationDataDir());
QFileInfo Pffi = QFileInfo(Pff);
if (Pffi.exists())
{
QString PrefsPfad;
if (Pffi.isDir())
PrefsPfad = Pff;
else
PrefsPfad = QDir::homePath();
QString prefsXMLFile=QDir::toNativeSeparators(PrefsPfad + "/prefs140.xml");
QFileInfo infoPrefsFile(prefsXMLFile);
if (infoPrefsFile.exists())
{
PrefsFile* prefsFile = new PrefsFile(prefsXMLFile);
if (prefsFile) {
PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
if (userprefsContext) {
QString prefslang = userprefsContext->get("gui_language","");
if (!prefslang.isEmpty())
langs.push_back(prefslang);
}
}
delete prefsFile;
}
}
if (!(lang = ::getenv("LC_ALL")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LANG")).isEmpty())
langs.push_back(lang);
#if defined(_WIN32)
wchar_t out[256];
QString language, sublanguage;
LCID lcIdo = GetUserDefaultLCID();
WORD sortId = SORTIDFROMLCID(lcIdo);
LANGID langId = GetUserDefaultUILanguage();
LCID lcIdn = MAKELCID(langId, sortId);
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) )
{
language = QString::fromUtf16( (ushort*)out );
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) )
{
sublanguage = QString::fromUtf16( (ushort*)out ).toLower();
lang = language;
if ( sublanguage != language && !sublanguage.isEmpty() )
lang += "_" + sublanguage.toUpper();
langs.push_back(lang);
}
}
#endif
langs.push_back(QString(QLocale::system().name()));
// remove duplicate entries...
QStringList::Iterator it = langs.end();
while (it != langs.begin())
{
--it;
if (langs.count(*it) > 1)
it = langs.erase(it);
}
return langs;
}
示例5: qt_parseSpoolInterface
// IRIX 6.x
void qt_parseSpoolInterface(QList<QPrinterDescription> *printers)
{
QDir lp(QLatin1String("/usr/spool/lp/interface"));
if (!lp.exists())
return;
QFileInfoList files = lp.entryInfoList();
if(files.isEmpty())
return;
for (int i = 0; i < files.size(); ++i) {
QFileInfo printer = files.at(i);
if (!printer.isFile())
continue;
// parse out some information
QFile configFile(printer.filePath());
if (!configFile.open(QIODevice::ReadOnly))
continue;
QByteArray line;
line.resize(1025);
QString namePrinter;
QString hostName;
QString hostPrinter;
QString printerType;
QString nameKey(QLatin1String("NAME="));
QString typeKey(QLatin1String("TYPE="));
QString hostKey(QLatin1String("HOSTNAME="));
QString hostPrinterKey(QLatin1String("HOSTPRINTER="));
while (!configFile.atEnd() &&
(configFile.readLine(line.data(), 1024)) > 0) {
QString uline = QString::fromLocal8Bit(line);
if (uline.startsWith(typeKey) ) {
printerType = uline.mid(nameKey.length());
printerType = printerType.simplified();
} else if (uline.startsWith(hostKey)) {
hostName = uline.mid(hostKey.length());
hostName = hostName.simplified();
} else if (uline.startsWith(hostPrinterKey)) {
hostPrinter = uline.mid(hostPrinterKey.length());
hostPrinter = hostPrinter.simplified();
} else if (uline.startsWith(nameKey)) {
namePrinter = uline.mid(nameKey.length());
namePrinter = namePrinter.simplified();
}
}
configFile.close();
printerType = printerType.trimmed();
if (printerType.indexOf(QLatin1String("postscript"), 0, Qt::CaseInsensitive) < 0)
continue;
int ii = 0;
while ((ii = namePrinter.indexOf(QLatin1Char('"'), ii)) >= 0)
namePrinter.remove(ii, 1);
if (hostName.isEmpty() || hostPrinter.isEmpty()) {
qt_perhapsAddPrinter(printers, printer.fileName(),
QLatin1String(""), namePrinter);
} else {
QString comment;
comment = namePrinter;
comment += QLatin1String(" (");
comment += hostPrinter;
comment += QLatin1Char(')');
qt_perhapsAddPrinter(printers, printer.fileName(),
hostName, comment);
}
}
}
示例6: writebinarytochunkswithcolor
void beamtest::writebinarytochunkswithcolor()
{
QFileInfo fileInfo;
QString filename = QFileDialog::getOpenFileName ( this,tr("Import File"),
"",tr( "All point cloud formats (*.ptx);;"
"XYZ (*.xyz *XYZ);;"
"PTX (*.ptx *.PTX)"));
int chunk = 2000000;
//int numfiles = floor((double) shapecount / (double) chunk);
int shapecounter=0;
int filecounter = 0;
double chunksize= 2000000;
int count =0;
int debugcount = 0;
char buf[1024];
QFile file(filename);
qint64 lineLength=0;
QStringList linelist;
QString filename2 = QFileDialog::getSaveFileName(this, tr("SaveBinary"), " ",tr("dat (*.dat "));
QFile file2(filename2);
file2.open(QIODevice::WriteOnly);
QDataStream out(&file2); // we will serialize the data into the file
fileInfo.setFile(filename2);
QString dirname = fileInfo.absoluteDir().absolutePath();
filename = fileInfo.fileName();
QString basename = fileInfo.baseName();
QString bundlename = fileInfo.bundleName();
if (file.open(QFile::ReadOnly)) {
do {
lineLength = file.readLine(buf, sizeof(buf));
if (lineLength != -1) {
QString line(buf);
linelist = line.split(tr(" "));
if (linelist.size() == 4)
{
double x = linelist.at(0).toDouble();
double y = linelist.at(1).toDouble();
double z = linelist.at(2).toDouble();
double intensity= linelist.at(3).toDouble();
if(x != 0 && y != 0 && z != 0 )
{
count++;
shapecounter++;
if(shapecounter == chunk)
{
shapecounter = 0;
filecounter++;
QString curfilename = dirname + tr("/") + basename + QString::number(filecounter) + tr(".data");
file2.close();
file2.setFileName(curfilename);
file2.open(QFile::WriteOnly);
}
if (count % 100000 == 0) qDebug() << count;
out << x << y << z << intensity;
}
}
//if (count > 10000) break;
}
}while (lineLength != -1);
}
if(file2.isOpen()) file2.close();
}
示例7: generate
extern "C" Q_DECL_EXPORT
int generate()
{
Options::headerList = ParserOptions::headerList;
QFileInfo smokeConfig;
const QStringList& args = QCoreApplication::arguments();
for (int i = 0; i < args.count(); i++) {
if ((args[i] == "-m" || args[i] == "-p" || args[i] == "-pm" || args[i] == "-o" ||
args[i] == "-st" || args[i] == "-vt" || args[i] == "-smokeconfig") && i + 1 >= args.count())
{
qCritical() << "generator_smoke: not enough parameters for option" << args[i];
return EXIT_FAILURE;
} else if (args[i] == "-m") {
Options::module = args[++i];
} else if (args[i] == "-p") {
bool ok = false;
Options::parts = args[++i].toInt(&ok);
if (!ok) {
qCritical() << "generator_smoke: couldn't parse argument for option" << args[i - 1];
return EXIT_FAILURE;
}
} else if (args[i] == "-pm") {
Options::parentModules = args[++i].split(',');
} else if (args[i] == "-st") {
Options::scalarTypes = args[++i].split(',');
} else if (args[i] == "-vt") {
Options::voidpTypes = args[++i].split(',');
} else if (args[i] == "-smokeconfig") {
smokeConfig = QFileInfo(args[++i]);
} else if (args[i] == "-o") {
Options::outputDir = QDir(args[++i]);
} else if (args[i] == "-h" || args[i] == "--help") {
showUsage();
return EXIT_SUCCESS;
}
}
if (smokeConfig.exists()) {
QFile file(smokeConfig.filePath());
file.open(QIODevice::ReadOnly);
QDomDocument doc;
doc.setContent(file.readAll());
file.close();
QDomElement root = doc.documentElement();
QDomNode node = root.firstChild();
while (!node.isNull()) {
QDomElement elem = node.toElement();
if (elem.isNull()) {
node = node.nextSibling();
continue;
}
if (elem.tagName() == "outputDir") {
Options::outputDir = QDir(elem.text());
} else if (elem.tagName() == "moduleName") {
Options::module = elem.text();
} else if (elem.tagName() == "parts") {
Options::parts = elem.text().toInt();
} else if (elem.tagName() == "parentModules") {
QDomNode parent = elem.firstChild();
while (!parent.isNull()) {
QDomElement elem = parent.toElement();
if (elem.isNull()) {
parent = parent.nextSibling();
continue;
}
if (elem.tagName() == "module") {
Options::parentModules << elem.text();
}
parent = parent.nextSibling();
}
} else if (elem.tagName() == "scalarTypes") {
QDomNode typeName = elem.firstChild();
while (!typeName.isNull()) {
QDomElement elem = typeName.toElement();
if (elem.isNull()) {
typeName = typeName.nextSibling();
continue;
}
if (elem.tagName() == "typeName") {
Options::scalarTypes << elem.text();
}
typeName = typeName.nextSibling();
}
} else if (elem.tagName() == "voidpTypes") {
QDomNode typeName = elem.firstChild();
while (!typeName.isNull()) {
QDomElement elem = typeName.toElement();
if (elem.isNull()) {
typeName = typeName.nextSibling();
continue;
}
if (elem.tagName() == "typeName") {
Options::voidpTypes << elem.text();
}
typeName = typeName.nextSibling();
}
} else if (elem.tagName() == "classList") {
QDomNode klass = elem.firstChild();
//.........这里部分代码省略.........
示例8: qt_win_get_open_file_names
QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
QString *initialDirectory,
QString *selectedFilter)
{
QFileInfo fi;
QDir dir;
if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:"))
initialDirectory->remove(0, 5);
fi = QFileInfo(*initialDirectory);
if (initialDirectory && !fi.isDir()) {
*initialDirectory = fi.absolutePath();
}
if (!fi.exists())
*initialDirectory = QDir::homePath();
DWORD selFilIdx = 0;
QStringList filterLst = qt_win_make_filters_list(args.filter);
int idx = 0;
if (selectedFilter) {
idx = filterLst.indexOf(*selectedFilter);
}
// Windows Vista (& above) allows users to search from file dialogs. If user selects
// multiple files belonging to different folders from these search results, the
// GetOpenFileName() will return only one folder name for all the files. To retrieve
// the correct path for all selected files, we have to use Common Item Dialog interfaces.
#ifndef Q_WS_WINCE
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
return qt_win_CID_get_open_file_names(args, initialDirectory, filterLst, selectedFilter, idx);
#endif
QStringList result;
QDialog modal_widget;
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFiles,
args.options);
if (idx)
ofn->nFilterIndex = idx + 1;
if (GetOpenFileName(ofn)) {
QString fileOrDir = QString::fromWCharArray(ofn->lpstrFile);
selFilIdx = ofn->nFilterIndex;
int offset = fileOrDir.length() + 1;
if (ofn->lpstrFile[offset] == 0) {
// Only one file selected; has full path
fi.setFile(fileOrDir);
QString res = fi.absoluteFilePath();
if (!res.isEmpty())
result.append(res);
}
else {
// Several files selected; first string is path
dir.setPath(fileOrDir);
QString f;
while(!(f = QString::fromWCharArray(ofn->lpstrFile + offset)).isEmpty()) {
fi.setFile(dir, f);
QString res = fi.absoluteFilePath();
if (!res.isEmpty())
result.append(res);
offset += f.length() + 1;
}
}
}
qt_win_clean_up_OFN(&ofn);
QApplicationPrivate::leaveModal(&modal_widget);
qt_win_eatMouseMove();
if (!result.isEmpty()) {
*initialDirectory = fi.path(); // only save the path if there is a result
if (selectedFilter)
*selectedFilter = qt_win_selected_filter(args.filter, selFilIdx);
}
return result;
}
示例9: HandleEntry
bool PackageProcessor::HandleEntry (int packageId, const QFileInfo& fi,
const QString& stagingDir, QDir& packageDir)
{
QFile dbFile (DBDir_.filePath (QString::number (packageId)));
if (!dbFile.open (QIODevice::WriteOnly | QIODevice::Append))
{
qWarning () << Q_FUNC_INFO
<< "could not open DB file"
<< dbFile.fileName ()
<< "for write:"
<< dbFile.errorString ();
return false;
}
QString sourceName = fi.absoluteFilePath ();
sourceName = sourceName.mid (stagingDir.length ());
if (sourceName.at (0) == '/')
sourceName = sourceName.mid (1);
if (fi.isFile ())
{
QString destName = packageDir.filePath (sourceName);
#ifndef QT_NO_DEBUG
qDebug () << Q_FUNC_INFO
<< "gotta copy"
<< fi.absoluteFilePath ()
<< "to"
<< destName;
#endif
QFile file (fi.absoluteFilePath ());
if (!file.copy (destName))
{
qWarning () << Q_FUNC_INFO
<< "could not copy"
<< fi.absoluteFilePath ()
<< "to"
<< destName
<< "because of"
<< file.errorString ();
QString errorString = tr ("Could not copy file %1 because of %2.")
.arg (sourceName)
.arg (file.errorString ());
emit packageInstallError (packageId, errorString);
return false;
}
}
else if (fi.isDir ())
{
#ifndef QT_NO_DEBUG
qDebug () << Q_FUNC_INFO
<< "gotta create"
<< sourceName
<< "for"
<< fi.absoluteFilePath ();
#endif
if (!packageDir.mkpath (sourceName))
{
qWarning () << Q_FUNC_INFO
<< "unable to mkdir"
<< sourceName
<< "in"
<< packageDir.path ();
QString errorString = tr ("Unable to create directory %1.")
.arg (sourceName);
emit packageInstallError (packageId, errorString);
return false;
}
}
dbFile.write (sourceName.toUtf8 ());
dbFile.write ("\n");
return true;
}
示例10:
FileMatchContext::FileMatchContext(const QFileInfo &fi) :
m_fileInfo(fi),
m_fileName(fi.fileName()),
m_state(fi.isFile() && fi.isReadable() && fi.size() > 0 ? DataNotRead : NoDataAvailable)
{
}
示例11: sender
void PackageProcessor::handlePackageUnarchFinished (int ret, QProcess::ExitStatus)
{
sender ()->deleteLater ();
QProcess *unarch = qobject_cast<QProcess*> (sender ());
int packageId = unarch->property ("PackageID").toInt ();
QString stagingDir = unarch->property ("StagingDirectory").toString ();
Mode mode = static_cast<Mode> (unarch->property ("Mode").toInt ());
if (ret)
{
QString errString = QString::fromUtf8 (unarch->readAllStandardError ());
qWarning () << Q_FUNC_INFO
<< "unpacker exited with"
<< ret
<< errString
<< "for"
<< packageId
<< unarch->property ("Path").toString ();
QString errorString = tr ("Unable to unpack package archive, unpacker exited with %1: %2.")
.arg (ret)
.arg (errString);
emit packageInstallError (packageId, errorString);
CleanupDir (stagingDir);
return;
}
int oldId = -1;
if (mode == MUpdate)
{
oldId = Core::Instance ().GetStorage ()->FindInstalledPackage (packageId);
if (!CleanupBeforeUpdate (oldId, packageId))
{
qWarning () << Q_FUNC_INFO
<< "unable to cleanup";
return;
}
}
QDir packageDir;
try
{
packageDir = Core::Instance ().GetPackageDir (packageId);
}
catch (const std::exception& e)
{
qWarning () << Q_FUNC_INFO
<< "while trying to get dir for package"
<< packageId
<< "got we exception"
<< e.what ();
QString errorString = tr ("Unable to get directory for the package: %1.")
.arg (QString::fromUtf8 (e.what ()));
emit packageInstallError (packageId, errorString);
CleanupDir (stagingDir);
return;
}
QDirIterator dirIt (stagingDir,
QDir::NoDotAndDotDot |
QDir::Readable |
QDir::NoSymLinks |
QDir::Dirs |
QDir::Files,
QDirIterator::Subdirectories);
while (dirIt.hasNext ())
{
dirIt.next ();
QFileInfo fi = dirIt.fileInfo ();
if (fi.isDir () ||
fi.isFile ())
if (!HandleEntry (packageId, fi, stagingDir, packageDir))
{
try
{
Remove (packageId);
}
catch (const std::exception& e)
{
qWarning () << Q_FUNC_INFO
<< "while removing partially installed package"
<< packageId
<< "got:"
<< e.what ();
}
QString errorString = tr ("Unable to copy "
"files from staging area to "
"destination directory.");
emit packageInstallError (packageId, errorString);
CleanupDir (stagingDir);
return;
}
}
switch (mode)
//.........这里部分代码省略.........
示例12: loadSpawnPoints
void SpawnMonitor::loadSpawnPoints()
{
QString fileName;
fileName = m_zoneName + ".sp";
QFileInfo fileInfo =
m_dataLocMgr->findExistingFile("spawnpoints", fileName, false);
if (!fileInfo.exists())
{
seqWarn("Can't find spawn point file %s",
(const char*)fileInfo.absFilePath());
return;
}
fileName = fileInfo.absFilePath();
QFile spFile(fileName);
if (!spFile.open(IO_ReadOnly))
{
seqWarn( "Can't open spawn point file %s", (const char*)fileName );
return;
}
QTextStream input( &spFile );
int16_t x, y, z;
unsigned long diffTime;
uint32_t count;
QString name;
while (!input.atEnd())
{
input >> x;
input >> y;
input >> z;
input >> diffTime;
input >> count;
name = input.readLine();
name = name.stripWhiteSpace();
EQPoint loc(x, y, z);
SpawnPoint* p = new SpawnPoint( 0, loc, name, diffTime, count );
if (p)
{
QString key = p->key();
if (!m_points.find(key))
{
m_points.insert(key, p);
emit newSpawnPoint(p);
}
else
{
seqWarn("Warning: spawn point key already in use!");
delete p;
}
}
}
seqInfo("Loaded spawn points: %s", (const char*)fileName);
m_modified = false;
}
示例13: seqWarn
void SpawnMonitor::saveSpawnPoints()
{
// only save if modified
if (!m_modified)
return;
if ( !m_zoneName.length() )
{
seqWarn("Zone name not set in 'SpawnMonitor::saveSpawnPoints'!" );
return;
}
QString fileName;
fileName = m_zoneName + ".sp";
QFileInfo fileInfo =
m_dataLocMgr->findWriteFile("spawnpoints", fileName, false);
fileName = fileInfo.absFilePath();
QString newName = fileName + ".new";
QFile spFile( newName );
if (!spFile.open(IO_WriteOnly))
{
seqWarn("Failed to open %s for writing", (const char*)newName);
return;
}
QTextStream output(&spFile);
QAsciiDictIterator<SpawnPoint> it( m_points );
SpawnPoint* sp;
while ((sp = it.current()))
{
++it;
output << sp->x()
<< " "
<< sp->y()
<< " "
<< sp->z()
<< " "
<< (unsigned long)sp->diffTime()
<< " "
<< sp->count()
<< " "
<< sp->name()
<< '\n';
}
spFile.close();
QFileInfo fi( spFile );
QFile old( fileName );
QDir dir( fi.dir() );
QString backupName = fileName + ".bak";
if (old.exists())
{
if (dir.rename( fileName, backupName))
{
if (!dir.rename( newName, fileName))
seqWarn( "Failed to rename %s to %s",
(const char*)newName, (const char*)fileName);
}
}
else
{
if (!dir.rename(newName, fileName))
seqWarn("Failed to rename %s to %s",
(const char*)newName, (const char*)fileName);
}
m_modified = false;
seqInfo("Saved spawn points: %s", (const char*)fileName);
}
示例14: onLoad
void VSFolderObserver::onLoad( const QFileInfo& path )
{
/**/
volatile QString hoge = path.absoluteFilePath();
QFile scriptFile( path.absoluteFilePath() );
if( !scriptFile.exists() )
{
/* TODO ログ */
return ;
}
/* ロードするインデックスを判定 */
ShaderScripts& shaderScripts = cxt_->shaderScripts;
ShaderScriptGroup& vsScripts = shaderScripts.vsScripts;
int vi;
for( vi=0;vi<vsScripts.numScript;++vi)
{
const ShaderScriptGroup& scriptGroup = vsScripts;
const ShaderScript& script = scriptGroup.scripts[vi];
QByteArray baBaseName = path.baseName().toLocal8Bit();
if( !strcmp( baBaseName.data(), script.name ) )
{
NL_SAFE_RELEASE( cxt_->vss[vi].shader_ );
NL_SAFE_RELEASE( cxt_->vss[vi].inputLayout_ );
break;
}
}
/**/
ShaderScript& script = vsScripts.scripts[vi];
/* ロードが初の場合 */
if( vi == vsScripts.numScript )
{
/* 総ロード数を増やす */
++vsScripts.numScript;
/* IDの再登録 */
setId( groupName_, path.baseName() );
}
/* リロードになる場合 */
else
{
/* スクリプト文字列の解放 */
if( script.name )
{
free( script.name );
script.name = NULL;
}
if( script.script )
{
free( script.script );
script.script = NULL;
}
}
/**/
scriptFile.open(QIODevice::ReadOnly|QIODevice::Text);
QByteArray scriptData = scriptFile.readAll();
script.script = (nlInt8*)calloc((scriptData.size()+1)*sizeof(nlInt8),1);
strcpy( script.script, scriptData.data() );
QByteArray baBaseName = path.baseName().toLocal8Bit();
script.name = (nlInt8*)calloc((baBaseName.size()+1)*sizeof(nlInt8),1);
strcpy( script.name, baBaseName.data() );
/* ターゲットをロードする */
nlCreateShaders( ShaderType_VS, vi, shaderScripts, *cxt_ );
}
示例15: processXmlFile
bool processXmlFile(const QString &xmlFile)
{
QFile file(xmlFile);
if (!file.open(QIODevice::ReadOnly))
return false;
const QLatin1String tag_app("app");
const QLatin1String attrib_mainQmlFile("mainqmlfile");
const QLatin1String attrib_projectPath("projectpath");
const QLatin1String attrib_projectName("projectname");
const QLatin1String attrib_screenOrientation("screenorientation");
const QLatin1String value_screenOrientationLockLandscape("LockLandscape");
const QLatin1String value_screenOrientationLockPortrait("LockPortrait");
const QLatin1String attrib_networkAccess("networkaccess");
static const QString qtDir =
QLibraryInfo::location(QLibraryInfo::PrefixPath) + QLatin1Char('/');
QXmlStreamReader reader(&file);
while (!reader.atEnd()) {
const QXmlStreamReader::TokenType token = reader.readNext();
switch (token) {
case QXmlStreamReader::StartElement:
if (reader.name() == tag_app) {
QtQuickApp app;
QFileInfo projectPath;
if (!reader.attributes().hasAttribute(attrib_projectPath)) {
qDebug() << "Project without path found";
continue;
}
projectPath = qtDir + reader.attributes().value(attrib_projectPath).toString();
app.setProjectPath(projectPath.absoluteFilePath());
if (reader.attributes().hasAttribute(attrib_mainQmlFile)) {
const QFileInfo qmlFileOrigin(
qtDir + reader.attributes().value(attrib_mainQmlFile).toString());
if (!qmlFileOrigin.exists()) {
qDebug() << "Cannot find" <<
QDir::toNativeSeparators(qmlFileOrigin.absoluteFilePath());
continue;
}
const QFileInfo qmlTargetPath(QString(projectPath.absoluteFilePath()
+ QLatin1Char('/') + qmlFileOrigin.baseName()
+ QLatin1String("/qml")));
#ifdef Q_OS_WIN
const QString sourcePath =
QDir::toNativeSeparators(qmlFileOrigin.canonicalPath() + QLatin1String("/*"));
const QString targetPath =
QDir::toNativeSeparators(qmlTargetPath.absoluteFilePath() + QLatin1Char('/'));
QProcess xcopy;
QStringList parameters;
parameters << QLatin1String("/E") << sourcePath << targetPath;
xcopy.start(QLatin1String("xcopy.exe"), parameters);
if (!xcopy.waitForStarted() || !xcopy.waitForFinished()) {
qDebug() << "Could not copy" <<
QDir::toNativeSeparators(sourcePath);
continue;
}
#else // Q_OS_WIN
// Implement me!
#endif // Q_OS_WIN
app.setMainQmlFile(qmlTargetPath.absoluteFilePath()
+ QLatin1Char('/') + qmlFileOrigin.fileName());
}
app.setProjectName(reader.attributes().hasAttribute(attrib_projectName)
? reader.attributes().value(attrib_projectName).toString()
: QFileInfo(app.mainQmlFile()).baseName());
if (reader.attributes().hasAttribute(attrib_screenOrientation)) {
const QStringRef orientation = reader.attributes().value(attrib_screenOrientation);
app.setOrientation(orientation == value_screenOrientationLockLandscape ?
AbstractMobileApp::ScreenOrientationLockLandscape
: orientation == value_screenOrientationLockPortrait ?
AbstractMobileApp::ScreenOrientationLockPortrait
: AbstractMobileApp::ScreenOrientationAuto);
}
if (reader.attributes().hasAttribute(attrib_networkAccess))
app.setNetworkEnabled(
reader.attributes().value(attrib_networkAccess).toString() == QLatin1String("true"));
if (!app.generateFiles(0))
qDebug() << "Unable to generate the files for" << app.projectName();
}
break;
default:
break;
}
}
return true;
}