int Packer::Pack(const QString &sourceFolderLocation, const QString &destinationArchiveLocation) { //Open the source folder and create the destination archive file QFileInfo folderInfo(sourceFolderLocation); if (!folderInfo.exists() || !folderInfo.isReadable()) return 1; //unable to read the source folder if (!folderInfo.isDir()) return 2; //source folder is not a directory //Open the source folder and make sure it isn't empty QDir dir(sourceFolderLocation); if (dir.count() == 0) return 3; //directory is empty //Create the archive file and write the header QFile file(destinationArchiveLocation); if (!file.open(QFile::ReadWrite | QFile::Truncate)) return 3; //unable to create the archive file if (!this->Write_Archive_Header(file, folderInfo)) return 4; //unable to write the archive file header //Pack all of the files if (!this->Pack_Directory(file, sourceFolderLocation)) return 5; //unable to pack the directory //Write the scramble key to the end of the file if it was used if (!file.seek(file.size())) return 6; //unable to write scramble key assert(this->scrambler); QByteArray buffer(1, 0x00); buffer.data()[0] = static_cast<char>(this->scrambler->Get_Scramble_Key()); if (file.write(buffer) != buffer.size()) return 6; //unable to write scramble key return 0; }
void KNFileSearcher::analysisFolder(const QString &folderPath) { QDir folderInfo(folderPath); //Get the entry file info under the folder. QFileInfoList contents=folderInfo.entryInfoList(); for(auto i=contents.begin(); i!=contents.end(); ++i) { QString currentName=(*i).fileName(); //Ignore dot and dotdot. if(currentName=="." || currentName=="..") { continue; } //Analysis item. if((*i).isFile()) { emit requireAnalysisFile((*i).suffix(), (*i).absoluteFilePath()); } if((*i).isDir()) { emit requireAnlaysisFolder((*i).absoluteFilePath()); } } }
void FolderFilesList::run() { m_files.clear(); QFileInfo folderInfo(m_folder); checkNextItem(folderInfo); if (m_cancelSearch) m_files.clear(); }
void UIWizardNewVDPage3::onSelectLocationButtonClicked() { /* Get current folder and filename: */ QFileInfo fullFilePath(mediumPath()); QDir folder = fullFilePath.path(); QString strFileName = fullFilePath.fileName(); /* Set the first parent folder that exists as the current: */ while (!folder.exists() && !folder.isRoot()) { QFileInfo folderInfo(folder.absolutePath()); if (folder == QDir(folderInfo.absolutePath())) break; folder = folderInfo.absolutePath(); } /* But if it doesn't exists at all: */ if (!folder.exists() || folder.isRoot()) { /* Use recommended one folder: */ QFileInfo defaultFilePath(absoluteFilePath(strFileName, m_strDefaultPath)); folder = defaultFilePath.path(); } /* Prepare backends list: */ QVector<QString> fileExtensions; QVector<KDeviceType> deviceTypes; CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>(); mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); QStringList validExtensionList; for (int i = 0; i < fileExtensions.size(); ++i) if (deviceTypes[i] == KDeviceType_HardDisk) validExtensionList << QString("*.%1").arg(fileExtensions[i]); /* Compose full filter list: */ QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" ")); /* Open corresponding file-dialog: */ QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), strBackendsList, thisImp(), VBoxGlobal::tr("Please choose a location for new virtual hard drive file")); /* If there was something really chosen: */ if (!strChosenFilePath.isEmpty()) { /* If valid file extension is missed, append it: */ if (QFileInfo(strChosenFilePath).suffix().isEmpty()) strChosenFilePath += QString(".%1").arg(m_strDefaultExtension); m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); m_pLocationEditor->selectAll(); m_pLocationEditor->setFocus(); } }
SharedFoldersWidget::SharedFoldersWidget(QWidget *parent) :QWidget(parent) ,client(nullptr) ,api(nullptr) { setupUi(this); foldersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); QTimer *updateTimer = new QTimer(this); updateTimer->setInterval(2000); updateTimer->start(); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTick())); connect(addButton, SIGNAL(clicked()), this, SLOT(addFolder())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeFolder())); connect(infoButton, SIGNAL(clicked()), this, SLOT(folderInfo())); connect(foldersTable, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(itemDoubleClicked(QTableWidgetItem*))); }