FolderCreator::FolderCreator() : QbWindow(config.geometry.folderCreator) { setObjectName("folder-creator"); setWindowTitle("Create New Folder"); layout = new QVBoxLayout; layout->setMargin(Style::WindowMargin); layout->setSpacing(Style::WidgetSpacing); layout->setAlignment(Qt::AlignTop); setLayout(layout); label = new QLabel("Folder name:"); layout->addWidget(label); name = new QLineEdit; layout->addWidget(name); controlLayout = new QHBoxLayout; controlLayout->setAlignment(Qt::AlignRight); layout->addLayout(controlLayout); ok = new QPushButton("Ok"); controlLayout->addWidget(ok); cancel = new QPushButton("Cancel"); controlLayout->addWidget(cancel); connect(name, SIGNAL(returnPressed()), this, SLOT(createFolder())); connect(ok, SIGNAL(released()), this, SLOT(createFolder())); connect(cancel, SIGNAL(released()), this, SLOT(close())); }
BookmarkPropertiesDialog::BookmarkPropertiesDialog(const QUrl &url, const QString &title, const QString &description, BookmarksItem *folder, int index, bool isUrl, QWidget *parent) : Dialog(parent), m_bookmark(nullptr), m_index(index), m_ui(new Ui::BookmarkPropertiesDialog) { m_ui->setupUi(this); m_ui->folderComboBox->setCurrentFolder(folder ? folder : BookmarksManager::getLastUsedFolder()); m_ui->titleLineEdit->setText(title); m_ui->addressLineEdit->setText(url.toString()); m_ui->addressLineEdit->setVisible(isUrl); m_ui->addressLabel->setVisible(isUrl); m_ui->descriptionTextEdit->setPlainText(description); m_ui->visitsLabel->hide(); m_ui->visitsLabelWidget->hide(); m_ui->lastVisitLabel->hide(); m_ui->lastVisitLabelWidget->hide(); m_ui->addedLabel->hide(); m_ui->addedLabelWidget->hide(); m_ui->modifiedLabel->hide(); m_ui->modifiedLabelWidget->hide(); setWindowTitle(tr("Add Bookmark")); connect(m_ui->newFolderButton, SIGNAL(clicked()), m_ui->folderComboBox, SLOT(createFolder())); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveBookmark())); connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); }
void ZipTest::test_openAppendToZipWithFileAlreadyExisting() { bool expected = false; std::string zipFileName = tempFolder + "/" + zipFile; createFolder(zipFileName); copyFile(zipFile, zipFileName); //first open zip->open(zipFileName, OpenFlags::OpenExisting); std::string theString("Lorem Ipsum..."); std::vector<unsigned char> content; content.insert(content.end(), theString.begin(), theString.end()); zip->addFile("file1.txt", content); zip->close(); //second open zip->open(zipFileName, OpenFlags::OpenExisting); theString = "Lorem Ipsum Number 2..."; content.insert(content.end(), theString.begin(), theString.end()); bool actual = zip->addFile("file1.txt", content); zip->close(); CPPUNIT_ASSERT_EQUAL_MESSAGE("add", expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", true, containsFile(zipFileName, "file1.txt")); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 7, numFilesInZip(zipFileName)); }
TestRoadRunner::TestRoadRunner(const std::string& version, int caseNumber) : version(version), caseNumber(caseNumber), rr(0), simulation(0) { //fileName = getModelFileName(version, caseNumber); home = getenv("HOME"); dataOutputFolder = home + string("/tmp"); string dummy; string logFileName; string settingsFileName; //Create a log file name createTestSuiteFileNameParts(caseNumber, ".log", dummy, logFileName, settingsFileName); //Create subfolder for data output dataOutputFolder = joinPath(dataOutputFolder, getTestSuiteSubFolderName(caseNumber)); if(!createFolder(dataOutputFolder)) { string msg("Failed creating output folder for data output: " + dataOutputFolder); throw(Exception(msg)); } }
void CreateContactInstanceTask::onGo() { // are we creating a folder first or can we just proceed as normal? if ( m_folderDisplayName.isEmpty() ) RequestTask::onGo(); else // create the folder, when the folder has been created, onFolderCreated gets called and creates the contact createFolder(); }
bool checkFilePath(string paths) { string tmp; size_t end_pos = paths.rfind('/'); tmp = paths.substr(0, end_pos); paths = tmp; size_t pos = paths.find('/'); while(pos = paths.find("/", pos+1), pos != string::npos) { tmp = (paths.substr(0, pos)); if(!createFolder(tmp)) { return false; } } if(!createFolder(paths)) { return false; } return true; }
void DB::saveImgWithCnt(IplImage* img, const char* tag, unsigned cnt){ assert(img!=0); createFolder(_folderName.c_str()); sprintf(_text,"../db/%s/%05d_%s.jpg",_folderName.c_str(),_cnt, tag); cvSaveImage(_text,img); _cnt = cnt; }
void DB::saveImg(IplImage* img, const char* tag){ assert(strcmp(_folderName.c_str(),"none")!=0); assert(img!=0); createFolder(_folderName.c_str()); sprintf(_text,"../db/%s/%05d_%s.jpg",_folderName.c_str(),_cnt, tag); cvSaveImage(_text,img); }
void RecordingManager::Init() { framerate = Settings::GetInt("pourVideoFrameRate"); eachFrameDelay = 1100 / framerate; // padded since on playback it seems a bit fast framesToSkip = Settings::GetInt("pourVideoInitialFrameDelay"); string folder = Settings::GetString("pourVideoLocation"); folder = folder.substr(0, folder.find_last_of('/')+1); createFolder(folder); }
/*static*/ void CRhoFile::recursiveCreateDir(const char* szFolderPath, const char* szBasePath) { String strRelPath = String(szFolderPath).substr(strlen(szBasePath), strlen(szFolderPath) ); String strPath = szBasePath; CTokenizer oTokenizer( strRelPath, "/\\" ); while (oTokenizer.hasMoreTokens()) { String tok = oTokenizer.nextToken(); strPath = CFilePath::join(strPath, tok); createFolder(strPath.c_str()); } }
bool CCUtils::createIntermediateFolders(string path) { string parent = getParentPath(path); bool exist = isPathExistent(parent); bool success = true; if(!exist) { createIntermediateFolders(parent); success = createFolder(parent); } // return success flag return success; }
BookmarksImporterWidget::BookmarksImporterWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::BookmarksImporterWidget) { m_ui->setupUi(this); removeStateChanged(m_ui->removeCheckBox->checkState()); toSubfolderChanged(m_ui->toSubfolderCheckBox->checkState()); connect(m_ui->newFolderButton, SIGNAL(clicked()), m_ui->folderComboBox, SLOT(createFolder())); connect(m_ui->removeCheckBox, SIGNAL(toggled(bool)), this, SLOT(removeStateChanged(bool))); connect(m_ui->toSubfolderCheckBox, SIGNAL(toggled(bool)), this, SLOT(toSubfolderChanged(bool))); }
BookmarkPropertiesDialog::BookmarkPropertiesDialog(BookmarksItem *bookmark, QWidget *parent) : Dialog(parent), m_bookmark(bookmark), m_index(-1), m_ui(new Ui::BookmarkPropertiesDialog) { const BookmarksModel::BookmarkType type(static_cast<BookmarksModel::BookmarkType>(bookmark->data(BookmarksModel::TypeRole).toInt())); m_ui->setupUi(this); m_ui->folderComboBox->setCurrentFolder(dynamic_cast<BookmarksItem*>(bookmark->parent())); m_ui->titleLineEdit->setText(m_bookmark->data(BookmarksModel::TitleRole).toString()); m_ui->addressLineEdit->setText(m_bookmark->data(BookmarksModel::UrlRole).toString()); m_ui->addressLineEdit->setVisible(type == BookmarksModel::UrlBookmark); m_ui->addressLabel->setVisible(type == BookmarksModel::UrlBookmark); m_ui->descriptionTextEdit->setPlainText(m_bookmark->data(BookmarksModel::DescriptionRole).toString()); m_ui->keywordLineEdit->setText(m_bookmark->data(BookmarksModel::KeywordRole).toString()); m_ui->addedLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeAddedRole).isValid() ? m_bookmark->data(BookmarksModel::TitleRole).toDateTime().toString() : tr("Unknown")); m_ui->modifiedLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeModifiedRole).isValid() ? m_bookmark->data(BookmarksModel::TimeModifiedRole).toDateTime().toString() : tr("Unknown")); if (type == BookmarksModel::UrlBookmark) { m_ui->lastVisitLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeVisitedRole).isValid() ? m_bookmark->data(BookmarksModel::TimeVisitedRole).toString() : tr("Unknown")); m_ui->visitsLabelWidget->setText(QString::number(m_bookmark->data(BookmarksModel::VisitsRole).toInt())); } else { m_ui->visitsLabel->hide(); m_ui->visitsLabelWidget->hide(); m_ui->lastVisitLabel->hide(); m_ui->lastVisitLabelWidget->hide(); } if (bookmark->data(BookmarksModel::IsTrashedRole).toBool()) { setWindowTitle(tr("View Bookmark")); m_ui->folderLabel->hide(); m_ui->folderComboBox->hide(); m_ui->newFolderButton->hide(); m_ui->titleLineEdit->setReadOnly(true); m_ui->addressLineEdit->setReadOnly(true); m_ui->descriptionTextEdit->setReadOnly(true); m_ui->keywordLineEdit->setReadOnly(true); } else { setWindowTitle(tr("Edit Bookmark")); } connect(m_ui->newFolderButton, SIGNAL(clicked()), m_ui->folderComboBox, SLOT(createFolder())); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveBookmark())); connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); }
void ZipTest::test_openAExistingZipFile() { bool expected = true; std::string zipFileName = tempFolder + "/" + zipFile; createFolder(zipFileName); copyFile(zipFile, zipFileName); bool actual = zip->open(zipFileName); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 0, numFilesInZip(zipFileName)); }
/** * Tests the creation of a simple folder. */ int createFolderTest() { int hr = SUCCESS; FAIL_BRK4(initAndLoadDisk()); FAIL_BRK4(initFS()); FAIL_BRK4(createFolder("bar")); Fail: saveAndCloseDisk(); PRINT_RESULTS("Create Folder Test"); return hr; }
void ZipTest::test_deleteFile_WhenFileNotExists() { bool expected = true; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); bool actual = zip->deleteFile(notExistingFileName); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 8, numFilesInZip(zipFileName)); }
/** * Create a number of folders */ int createFolders(char *dirBaseName, int numDirs) { int hr = SUCCESS; int i; char *dirName = malloc(strlen(dirBaseName) * sizeof(char) + 32); for (i = 0; i < numDirs; i++) { sprintf(dirName, "%s%04d", dirBaseName, i); FAIL_BRK4(createFolder(dirName)); } Fail: SAFE_FREE(dirName); return hr; }
Depot::Depot(const std::string& path) { createFolder(path.c_str()); std::string path_ = path + "/read_data.bin"; openAndLockFile(&read_data_, path_.c_str()); path_ = path + "/read_index.bin"; openAndLockFile(&read_index_, path_.c_str()); path_ = path + "/overlap_data.bin"; openAndLockFile(&overlap_data_, path_.c_str()); path_ = path + "/overlap_index.bin"; openAndLockFile(&overlap_index_, path_.c_str()); }
void ZipTest::test_deleteFolder() { bool expected = true; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); std::string folderToDelete = folderNameInsideZip + "/folder1"; bool actual = zip->deleteFolder(folderToDelete); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 5, numFilesInZip(zipFileName)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", false, containsFolder(zipFileName, folderToDelete)); }
void ZipTest::test_replaceFile_WhenFileNotExistsOnFileSystem(){ bool expected = false; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); std::string fileToReplace = folderNameInsideZip + "/file2.txt"; bool actual = zip->replaceFile(notExistingFileName, fileToReplace); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 7, numFilesInZip(zipFileName)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", false, containsFile(zipFileName, fileToReplace)); }
void setUp() { // Create the output dir outputDir = getTestDirFullPath(TEST_INPUT_DIR); createFolder(outputDir.c_str()); MediaSyncSourceParams params_; params_.setUrl(HTTPUPLOADER_URL); SyncSourceConfig* fssc = new SyncSourceConfig(); fssc->setURI("testMss"); // Create the FileSyncSource fmss = new FakeMediaSource(TEXT("testMss"), fssc, outputDir, params_); ssr = new SyncSourceReport("testMss"); fmss->setReport(ssr); }
void SessionServer::rloop() { if(!validHeader()) return; char cmd[_CMD_SIZE + 1]; cmd[_CMD_SIZE] = '\0'; if(!readSBuf(cmd, _CMD_SIZE)) return; if(strcmp(cmd, "cdr") == 0) createFolder(); else if(strcmp(cmd, "cfl") == 0) createFile(); else if(strcmp(cmd, "rdr") == 0) readFolder(); else if(strcmp(cmd, "cmd") == 0) changeModel(); else if(strcmp(cmd, "ofl") == 0) openFile(); else if(strcmp(cmd, "rfl") == 0) readFile(); else if(strcmp(cmd, "wfl") == 0) writeFile(); else if(strcmp(cmd, "skf") == 0) seekFile(); else if(strcmp(cmd, "tlf") == 0) tellFile(); else if(strcmp(cmd, "csf") == 0) closeFile(); else if(strcmp(cmd, "del") == 0) deleteItem(); else if(strcmp(cmd, "gsf") == 0) getItemSafeInfo(); // else if(strcmp(cmd, "fdk") == 0) // formatDisk(); else if(strcmp(cmd, "lgt") == 0) logout(); else if(strcmp(cmd, "aur") == 0) addUsr(); else if(strcmp(cmd, "cpd") == 0) changePsd(); else cmdError(); }
bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const QIcon &icon, const QString &folder) { if (url.isEmpty() || title.isEmpty() || folder.isEmpty()) { return false; } QImage image = icon.pixmap(16, 16).toImage(); if (image.isNull()) { image = IconProvider::emptyWebImage(); } if (!isFolder(folder)) { createFolder(folder); } QSqlQuery query; query.prepare("INSERT INTO bookmarks (url, title, folder, icon) VALUES (?,?,?,?)"); query.bindValue(0, url.toString()); query.bindValue(1, title); query.bindValue(2, folder); QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); image.save(&buffer, "PNG"); query.bindValue(3, buffer.data()); query.exec(); Bookmark bookmark; bookmark.id = query.lastInsertId().toInt(); bookmark.url = url; bookmark.title = title; bookmark.folder = folder; bookmark.image = image; bookmark.inSubfolder = isSubfolder(bookmark.folder); setLastFolder(folder); emit bookmarkAdded(bookmark); mApp->sendMessages(Qz::AM_BookmarksChanged, true); return true; }
void ZipTest::test_replaceFile_Content() { std::vector<unsigned char> content; content.push_back('a'); content.push_back('z'); content.push_back('7'); bool expected = true; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); std::string fileToReplace = folderNameInsideZip + "/file2.txt"; bool actual = zip->replaceFile(fileToReplace, content); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 8, numFilesInZip(zipFileName)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", true, containsFile(zipFileName, fileToReplace)); }
void ZipTest::test_deleteFiles() { bool expected = true; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); std::string fileToDelete1 = folderNameInsideZip + "/file1.txt"; std::string fileToDelete2 = folderNameInsideZip + "/file2.txt"; std::list<std::string> filesToDelete; filesToDelete.push_back(fileToDelete1); filesToDelete.push_back(fileToDelete2); bool actual = zip->deleteFiles(filesToDelete); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 6, numFilesInZip(zipFileName)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", false, containsFile(zipFileName, fileToDelete1)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", false, containsFile(zipFileName, fileToDelete2)); }
int QDesktopViewWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QListWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: iconClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 1: layoutDirection(); break; case 2: populatedDesktop(); break; case 3: resizeIcons(); break; case 4: createFolder(); break; case 5: createLauncher(); break; case 6: createEmptyFile(); break; case 7: showDesktopIcons(); break; case 8: execDesktopSettings(); break; default: ; } _id -= 9; } return _id; }
void ZipTest::test_deleteFile_CheckOtherFileContent() { bool expected = true; std::string zipFileName = tempFolder + "/" + zipFileFor_deleteAndReplace; createFolder(zipFileName); copyFile(zipFileFor_deleteAndReplace, zipFileName); zip->open(zipFileName, OpenFlags::OpenExisting); std::string fileToDelete = folderNameInsideZip + "/file1.txt"; bool actual = zip->deleteFile(fileToDelete); zip->close(); CPPUNIT_ASSERT_EQUAL(expected, actual); CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 7, numFilesInZip(zipFileName)); CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", false, containsFile(zipFileName, fileToDelete)); std::string fileNameToCheckContent = folderNameInsideZip + "/file2.txt"; std::string fileContent = getFileContentAsString(zipFileName, fileNameToCheckContent, ""); CPPUNIT_ASSERT_MESSAGE("FileContent begin", boost::algorithm::starts_with(fileContent, "Lorem ipsum dolor")); }
/*static*/ void CRhoFile::recursiveCreateDir(const char* szFolderPath, const char* szBasePath) { String strRelPath = String(szFolderPath).substr(strlen(szBasePath), strlen(szFolderPath) ); String strPath = szBasePath; // handle case when szBasePath is empty and szFolderPath is starting with / if (strPath.length() == 0 && strRelPath.length() > 0 && strRelPath[0] == '/') { strPath += '/'; } CTokenizer oTokenizer( strRelPath, "/\\" ); while (oTokenizer.hasMoreTokens()) { String tok = oTokenizer.nextToken(); strPath = CFilePath::join(strPath, tok); if (!isDirectory(strPath.c_str())) { createFolder(strPath.c_str()); } } }
void TLevelSet::loadFolder(TIStream &is, TFilePath folder) { std::string s; is.getTagParam("type", s); if (s == "default") setDefaultFolder(folder); while (!is.eos()) { std::string tagName; is.matchTag(tagName); if (tagName == "levels") { while (!is.eos()) { TPersist *p = 0; is >> p; TXshLevel *xshLevel = dynamic_cast<TXshLevel *>(p); if (xshLevel && !xshLevel->getChildLevel()) moveLevelToFolder(folder, xshLevel); } } else if (tagName == "folder") { is.getTagParam("name", s); TFilePath child = createFolder(folder, ::to_wstring(s)); loadFolder(is, child); } else throw TException("expected <levels> or <folder>"); is.closeChild(); }
void chanFileSystemDockWidget::createContextMenu() { m_actionArray[CreateFile]->setText("new file"); connect(m_actionArray[CreateFile], SIGNAL(triggered()), this, SLOT(createFile())); m_actionArray[CreateFolder]->setText("new folder"); connect(m_actionArray[CreateFolder], SIGNAL(triggered()), this, SLOT(createFolder())); m_actionArray[ImportFile]->setText("import file"); connect(m_actionArray[ImportFile], SIGNAL(triggered()), this, SLOT(importFile())); m_actionArray[RemoveFile]->setText("remove file"); connect(m_actionArray[RemoveFile], SIGNAL(triggered()), this, SLOT(removeFile())); m_actionArray[RemoveFolder]->setText("remove folder"); connect(m_actionArray[RemoveFolder], SIGNAL(triggered()), this, SLOT(removeFolder())); m_actionArray[RenameFile]->setText("rename file"); connect(m_actionArray[RenameFile], SIGNAL(triggered()), this, SLOT(renameFile())); m_actionArray[RenameFolder]->setText("rename folder"); connect(m_actionArray[RenameFolder], SIGNAL(triggered()), this, SLOT(renameFolder())); std::for_each(m_actionArray, m_actionArray + actionArraySize, [this](QAction* item) { this->addAction(item); }); setContextMenuPolicy(Qt::ContextMenuPolicy::ActionsContextMenu); }