void testGetCurrentCycle() { uint8_t array[] = {3, 1, 3, 1, 2, 3}; uint8_t clockSize = 6; printf("\n====================\n"); printf("get current cycle\n"); printf("====================\n"); printf("new test with: "); printClock(array, clockSize); SearchTreeNode *stn1 = newSearchTreeNode(NULL, array + 1); SearchTreeNode *stn0 = newSearchTreeNode(stn1, array); SearchTreeNode *stn3 = newSearchTreeNode(stn0, array + 3); SearchTreeNode *stn4 = newSearchTreeNode(stn3, array + 4); SearchTreeNode *stn2 = newSearchTreeNode(stn4, array + 2); SearchTreeNode *stn5 = newSearchTreeNode(stn2, array + 5); GArray * path = getCurrentPath(stn5); printf("assert that path has the length of the clock\n"); assert(path->len == clockSize); SearchTreeNode *pathnode = &g_array_index(path, SearchTreeNode, 0); printf("assert that the first element of the path is stn1\n"); assert(stn1->content == pathnode->content); pathnode = &g_array_index(path, SearchTreeNode, clockSize - 1); printf("assert that the last element of the path is stn5\n"); assert(stn5->content == pathnode->content); printPath(path, array); printf("add stn1 as child of stn5 (create contradiction)\n"); SearchTreeNode *stnLast = newSearchTreeNode(stn5, array + 1); printf("assert that contradicted path is null\n"); path = getCurrentPath(stnLast); assert(path == NULL); printf("assert that incomplete path is not null\n"); path = getCurrentPath(stn4); assert(path != NULL && path->len < clockSize); }
void QHexEdit::goToObject(IScaObject *object) { QString newPath = object->getFile().absoluteFilePath(); if (newPath != getCurrentPath() && !newPath.isEmpty()) { loadFromFile(newPath); } IScaObject::IScaObjectType type = object->getType(); switch (type) { case IScaObject::FILE: { break; } case IScaObject::DIRECTORY: { break; } case IScaObject::TEXTBLOCK: { IScaObjectTextBlock *obj = static_cast<IScaObjectTextBlock *>(object); goToTextBlock(obj); break; } case IScaObject::BINARYBLOCK: { IScaObjectBinaryBlock *obj = static_cast<IScaObjectBinaryBlock *>(object); goToBinaryBlock(obj); break; } case IScaObject::LINE: { IScaObjectLine *obj = static_cast<IScaObjectLine *>(object); goToLine(obj); break; } case IScaObject::IDENTIFIER: { IScaObjectIdentifier *obj = static_cast<IScaObjectIdentifier *>(object); goToIdentifier(obj); break; } case IScaObject::SYMBOL: { IScaObjectSymbol *obj = static_cast<IScaObjectSymbol *>(object); goToSymbol(obj); break; } case IScaObject::LINK: { break; } default: { qDebug() << "[ObjectTextViewer]: unknown type to go to."; break; } } }
int backupExists() { long backupCount = 0; char** backups = getFilesSingleFolder(getCurrentPath(),"backup", &backupCount); if (backupCount == 1) { printf("%ld backup was found\n", backupCount); } else { printf("%ld backups were found\n", backupCount); } FILE* backupFile = NULL; FILE* metaFile = openFile("pad00000.meta","rb"); int i = 0; for(i = 0; i < backupCount; i++) { backupFile = fopen(backups[i],"rb"); if (getFileSize(backupFile) == getFileSize(metaFile)) { fclose(metaFile); fclose(backupFile); return 1; } fclose(backupFile); } fclose(metaFile); return 0; }
void FileSelectionDialog::listItemSelectedCallback(ListBox::ItemSelectedCallbackData* cbData) { /* Get the selected list item's name: */ std::string item=cbData->listBox->getItem(cbData->selectedItem); /* Check if it's a file or directory: */ if(item[item.size()-1]=='/') { /* Remove all path buttons after the selected one: */ for(GLint i=pathButtonBox->getNumColumns()-1;i>selectedPathButton;--i) pathButtonBox->removeWidgets(i); /* Add a new path button for the selected directory: */ item.erase(item.end()-1); char pathButtonName[20]; snprintf(pathButtonName,sizeof(pathButtonName),"PathButton%04d",selectedPathButton); Button* pathButton=new Button(pathButtonName,pathButtonBox,item.c_str()); pathButton->setBorderWidth(pathButton->getBorderWidth()*0.5f); pathButton->getSelectCallbacks().add(this,&FileSelectionDialog::pathButtonSelectedCallback); /* Select the new path button: */ setSelectedPathButton(selectedPathButton+1); } else { /* Assemble the fully qualified name of the selected file: */ std::string selectedFileName=getCurrentPath(); selectedFileName.push_back('/'); selectedFileName+=item; /* Call the OK callbacks: */ OKCallbackData cbData(this,selectedFileName); okCallbacks.call(&cbData); } }
void initProgram() { bdoRootFolder = oneLevelDown(getCurrentPath()); if (!backupExists()) { createBackup(); } printf("\nCounting files...\n\n"); // Counts how many files there is in the "files_to_patch" folder assigns to filesToPatchCount, // and get all the file names in folders and sub folders and returns them as an array of strings char** fileNames = getAllFiles(FILES_TO_PATCH_FOLDER_NAME,"*",&filesToPatchCount); if (filesToPatchCount == 0) { printf("No files present in %s\n\n",FILES_TO_PATCH_FOLDER_NAME); system("PAUSE"); exit(1); } printf("%ld files were found in %s\n\n", filesToPatchCount, FILES_TO_PATCH_FOLDER_NAME); filesToPatch = (FileToPatch*)malloc(filesToPatchCount * sizeof(FileToPatch)); long i = 0; for (i = 0; i < filesToPatchCount; i++) { filesToPatch[i].fileName = fileNames[i]; filesToPatch[i].patched = 0; } }
/* * Path is not saved in linux without installer - added workspace to properties dialog. */ NewProject::NewProject(QWidget *parent) : QDialog(parent) { mypath = getCurrentPath(); path = new QLineEdit(mypath,this); path->setToolTip(tr("Directory for new project.")); QPushButton *btnBrowsePath = new QPushButton(this); btnBrowsePath->setText(tr("Browse")); name = new QLineEdit(this); name->setToolTip(tr("New project name and sub-directory.")); connect(name,SIGNAL(textChanged(QString)),this,SLOT(nameChanged())); path->setText(mypath+name->text()); QLabel *pathLabel = new QLabel(tr("Workspace")); QLabel *nameLabel = new QLabel(tr("Project Name")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(btnBrowsePath, SIGNAL(clicked()), this, SLOT(browsePath())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); okButton = (QPushButton*) buttonBox->buttons().at(0); cancelButton = (QPushButton*) buttonBox->buttons().at(1); if(okButton->text().contains("cancel",Qt::CaseInsensitive)) { okButton = (QPushButton*) buttonBox->buttons().at(1); cancelButton = (QPushButton*) buttonBox->buttons().at(1); } QLabel *create = new QLabel(this); create->setText(tr("Creating a new project:")); create->setFont(QFont(this->font().family(),this->font().pointSize()*1.5,QFont::Bold)); QLabel *inst = new QLabel(this); inst->setText(tr(" 1) Choose project workspace.\n 2) Set project name.\n\n" \ "A project folder with project name will be created in the workspace.\n" \ "The new folder will have a main .c file and a .side project file.\n")); QVBoxLayout *blay = new QVBoxLayout(this); QGridLayout *layout = new QGridLayout(); layout->addWidget(path,0,1,1,1); // tab order for widgets is according to add order layout->addWidget(name,1,1,1,1); layout->addWidget(btnBrowsePath,0,2,1,1); layout->addWidget(nameLabel,1,0,1,1); layout->addWidget(pathLabel,0,0,1,1); blay->addWidget(create); blay->addWidget(inst); blay->addLayout(layout); blay->addWidget(new QLabel(this)); blay->addWidget(buttonBox); setLayout(blay); buttonBox->setFocus(); int fontSize = path->fontInfo().pixelSize(); setMinimumWidth(mypath.length()*fontSize+100); setWindowFlags(Qt::Tool); }
void PolyQtAnnotation::onCoordinatesChanged() { _currentPath = getCurrentPath(_annotation->getCoordinates()); if (_type == "spline") { _polys = _currentPath.toFillPolygon(); if (!_closed && _polys.isClosed()) { _polys.pop_back(); } } }
//-------------------------------------------------------------------------- void BaseFileDialog::writeConfig() { if(!getConfigSection().empty()) { UISettings& ui = UISettings::getSingleton(); ui.beginBatch(); ui.setSetting<String>("CurrentPath", getConfigSection(), getCurrentPath()); ui.setSetting<size_t>("CurrentFilter", getConfigSection(), getCurrentFilter()); ui.setSetting<float>("SplitterHPosition", getConfigSection(), getSplitterHPosition()); ui.endBatch(); } }
void NewProject::showDialog() { int fontSize = path->fontInfo().pixelSize(); setMinimumWidth(mypath.length()*fontSize+100); mypath = getCurrentPath(); path->setText(mypath+name->text()); if(okButton == NULL) return; if(cancelButton == NULL) return; /* disable OK button until user has satisfied criteria. */ okButton->setDisabled(true); this->setWindowTitle(QString(ASideGuiKey)+tr(" New Project")); this->exec(); }
u8 *memoryLoad (item *file) { char ffPath[MAXPATHLEN]; u8 *memholder = NULL; memset(&ffPath, 0, sizeof(ffPath)); sprintf(ffPath, "%s/%s", getCurrentPath(0), file->name); printf("\t %s <-\n", ffPath); FILE * fp = fopen(ffPath, "rb"); if (fp == NULL) { return NULL; } printf("size : %i\n", file->size); memholder = malloc(file->size); if (memholder == NULL) { fclose(fp); return NULL; } if (fread(memholder, 1, file->size, fp) < file->size) { free(memholder); fclose(fp); return NULL; } fclose(fp); return memholder; }
void QHexEdit::loadFromFile(const QString &path) { QFileInfo fileInf(path); if (fileInf.size() > MAX_BINARY_FILE_SIZE) { QMessageBox::warning(this, ERROR_TOO_LARGE_BINARY_FILE_TITLE, ERROR_TOO_LARGE_BINARY_FILE_MSG.arg( QString::number(fileInf.size())), QMessageBox::Ok); return; } if (fileInf.size() > SCROLLED_BINARY_FILE_MAX_SIZE) { QMessageBox::warning(this, WARNING_LARGE_BINARY_FILE_TITLE, WARNING_LARGE_BINARY_FILE_TEXT); } //Check if the file has already been opened //or it is not file at all if (getCurrentPath() == fileInf.filePath() || !fileInf.isFile()) { return; } FileLoader *fLoader = new FileLoader(); fLoader->openFile(fileInf.filePath()); QByteArray arr; fLoader->loadToByteArray(arr); setCursorPosition(0); clearSelection(); setData(arr); setCurrentPath(fileInf.filePath()); fLoader->deleteLater(); }
//-------------------------------------------------------------------------- String BaseFileDialog::getCurrentFilename() const { return getCurrentPath() + getCurrentBasename(); }
void copyFile(char* srcFileName, char* cpyFileName) { char* currentPath = getCurrentPath(); copyFileTo(srcFileName,cpyFileName,currentPath,currentPath); }
/* Takes a string path and collapses it to find the absolute path without "." or ".." */ node *collapseFilePath(char *path) { int isQuoted = quotedString(path); if(isQuoted == -1) { printf("Error: File Path string not closed\n"); return NULL; } node *currentNode = NULL; char *checkedStr = NULL; if(!isQuoted) { currentNode = getCurrentPath(); checkedStr = parseString(path); if(checkedStr == NULL) { freePathReverse(currentNode); return NULL; } char *temp = (char *) malloc(strlen(checkedStr) + 8); if(temp == NULL) { printf("ERROR: No memory left to append uni to file path\n"); freePathReverse(currentNode); return NULL; } strncpy(temp, checkedStr, strlen(checkedStr) + 1); strncat(temp, ".jg3538", 8); currentNode = insertNode(currentNode, temp); free(temp); }else { if(path[1] != '/') { currentNode = getCurrentPath(); } path = removeQuotes(path); char temp[strlen(path)+1]; strncpy(temp, path, strlen(path)+1); char *base = basename(temp); if(strncmp(base, "..", 3) == 0 && strlen(base) == 2) { path = (char *) realloc(path, strlen(path) + 9); if(path == NULL) { printf("ERROR: No memory left to append uni to file path\n"); freePathReverse(currentNode); return NULL; } strncat(path, "/.jg3538", 8); }else { path = (char *) realloc(path, strlen(path) + 8); if(path == NULL) { printf("ERROR: No memory left to append uni to file path\n"); freePathReverse(currentNode); return NULL; } strncat(path, ".jg3538", 8); } char *token = strtok(path, "/"); while(token != NULL) { checkedStr = parseQuotedString(token); if(checkedStr == NULL) { freePathReverse(currentNode); free(path); return NULL; } currentNode = insertNode(currentNode, checkedStr); free(checkedStr); token = strtok(NULL, "/"); } free(path); } while(currentNode->prev != NULL) { currentNode = currentNode->prev; } return currentNode; }
CVString CVPath::getCurrentVREPath( void ) { CVString cvPath = getCurrentPath(); cvPath += "vre\\"; return cvPath; }
void generateReferenceFile() { printf("Generating reference file (it takes a while)..."); char command[2048] = ""; char* metaFileName = getLatestBackup(); if (strlen(metaFileName) == 0) { metaFileName = (char*) malloc(strlen("pad00000.meta") + 1); strcpy(metaFileName,"pad00000.meta"); } sprintf(command, "cd patcher_resources & quickbms.exe 2>NULL 1>reference_file.txt blackdesert_file_lister.bms \"%s", concatenate(getCurrentPath(),metaFileName)); system(command); remove("NULL"); long refFileSize = getFileSizeByName("patcher_resources/reference_file.txt"); if (refFileSize < 20000000) { sprintf(command, "cd patcher_resources & quickbms.exe blackdesert_file_lister.bms \"%s", concatenate(getCurrentPath(),metaFileName)); system(command); printf("\n\nFailed to generate reference_file_textures.txt, the reason is shown above\n"); if (refFileSize != 0) { printf(" The program can try using the created reference_file.txt instead,\n"); printf(" But it will not find a lot of files\n"); askConfirmation(); } else { printf("\nThe program cannot continue... Exiting"); system("PAUSE"); exit(1); } } else { printf("\nDone.\n\n"); } }
char* bdoRootFolder() { return (oneLevelDown(getCurrentPath())); }
int main(int argc, char* argv[]) { std::wstring blenderPath; if (argc == 1) { // no arguments were provided -- user probably just tried to run it // we'll provide the opportunity to change the directory through this, // even if it was already valid. if (!DoesFileExist(DIRECTORY_FILE_NAME)) { int result = MessageBox(NULL, L"It looks like Blender hasn't been located yet by this program. Would you like to do this now?", L"First time setup", MB_YESNOCANCEL | MB_ICONINFORMATION); if (result == IDYES) { PromptForBlender(blenderPath); } return 0; } ReadFromFile(DIRECTORY_FILE_NAME, blenderPath); if (!DoesFileExist(blenderPath)) { int result = MessageBox(NULL, L"Valid blender install not found. Would you like to do this now?", L"First time setup", MB_YESNOCANCEL | MB_ICONINFORMATION); if (result == IDYES) { PromptForBlender(blenderPath); } return 0; } int result = MessageBox(NULL, L"Looks like a blender install has already been located. Do you wish to change it?", L"Change blender location", MB_YESNOCANCEL | MB_ICONINFORMATION); if (result == IDYES) { PromptForBlender(blenderPath); } if (!VerifyXmlEntries()) { std::wstring message = L"There was a problem verifying that " + XmlFileName + L" contains the correct " L"entries to make Builder work with this utility."; MessageBox(NULL, message.c_str(), L"Error", MB_OK | MB_ICONERROR); } if (!VerifyScripts()) { MessageBox(NULL, L"One or more scripts are missing and replacing them failed.", L"Error", MB_OK | MB_ICONERROR); } return 0; } if (!EnsureValidBlenderDirectory(blenderPath)) { std::cerr << "Blender directory invalid! Cannot proceed." << std::endl; return 1; } if (argc > 2) { std::cerr << "Too many arguments!" << std::endl; return 1; } if (!VerifyScripts()) { std::cerr << "One or more scripts are missing and replacing them failed." << std::endl; return 1; } // first argument is of course the execution directory of this file. // second argument should be the location of the .blend file they wish to compile. std::wstring blendFile = sToW(argv[1]); std::wstring command; std::wstring programDir = sToW(getCurrentPath()); command = L"\"\"" + blenderPath + L"\" -b \"" + blendFile + L"\" -P " + SCRIPTS_DIRECTORY + SCRIPT_FILE_NAME + L" -- \"" + programDir + SCRIPTS_DIRECTORY + L"\""; _wsystem(command.c_str()); return 0; }
inline File() : path(getCurrentPath()) {}
Browser::Browser() { string input, destination, newpath; path = "/"; vector<string> params; // pass buffer manager.setBuffer(&buffer); string command; pwd = Folder(0, 0, "root"); // WELCOME //printw("%s", "## Welcome in Rapidshare Manager \n"); //printw("%s", "rs#~/ "); //refresh(); //move(linenum,6); //cout << "## Welcome in Rapidshare Manager" << endl; //cout << "rs#~/ "; while(true) { input = buffer.getCommand(); //getline(cin, input); //printw("---- %s -----", input.c_str()); trim(input); split(params, input, is_any_of(" ")); command = params[0]; if(command == "ls"){ manager.listFolder(pwd); } if(command == "help"){ showHelp(); } if(command == "mv"){ params = processParams(input, command, 2); mv(getCurrentPath(params[0]), getCurrentPath(params[1])); } if(command == "cd"){ params = processParams(input, "cd", 1); if(params[0] == ".."){ if(!pwd.isRoot()){ pwd = manager.getFolder(pwd.parent); path = pwd.path; }else{ path = "/"; } }else{ if(pwd.isRoot()){ path = pwd.path + params[0]; }else{ path = pwd.path + "/" + params[0]; } if(manager.getFolder(path).notFound()) { cout << "not found" << endl; }else{ pwd = manager.getFolder(path); } } } if(command == "cp"){ params = processParams(input, "cp", 2); if(params.size() == 2){ bool local = isLocal(params[0]); string destination; if(local){ destination = getCurrentPath(params[1]); path = params[0]; }else{ path = getCurrentPath(params[0]); destination = params[1]; } copy(path, destination, local); } } if(command == "pwd"){ cout << pwd.path << endl; } if(command == "play"){ params = processParams(input, command, 1); /*if(params.size() == 1){ bool isNumber = true; // jedna se o cislo? for(int i = 0; i < (int)params.size();i++){ if(!isdigit(params[0][i])){ isNumber = false; } } if(isNumber){ play(pwd.path, lexical_cast<int>(params[0])); }else{ play(getCurrentPath(params[0])); } }else{ cout << "Wrond number of params" << endl; }*/ } if(command == "clear"){ system("clear"); } if(command == "mkdir") { params = processParams(input, command, 1); mkdir(pwd.path, params[0]); } if(command == "rename"){ params = processParams(input, "rename", 2); path = getCurrentPath(params[0]); rename(path, params[1]); } if(command == "rm") { params = processParams(input, command, 1); path = getCurrentPath(params[0]); rm(path); } if(command == "exit"){ // ukoncime ncurses endwin(); exit(1); } //cout << "rs#~" << pwd.path << " "; buffer.changeStart("rs#~" + pwd.path + " "); buffer.writeStart(); }; cout << endl; }
bool FileSelectionDialog::readDirectory(void) { if(pipe==0||pipe->isMaster()) { /* Open the current directory: */ std::string fullPath=getCurrentPath(); DIR* directory=opendir(fullPath.c_str()); if(directory==0) { if(pipe!=0) { /* Send an error code to the slave nodes: */ pipe->write<int>(0); pipe->finishMessage(); } return false; } /* Read all directory entries: */ std::vector<std::string> directories; std::vector<std::string> files; struct dirent* dirEntry; while((dirEntry=readdir(directory))!=0) { /* Ignore hidden entries: */ if(dirEntry->d_name[0]!='.') { /* Determine the type of the directory entry: */ int entryType=0; // unkown, directory, file #ifdef _DIRENT_HAVE_D_TYPE if(dirEntry->d_type==DT_DIR) entryType=1; else if(dirEntry->d_type==DT_REG) entryType=2; #else std::string fullName=fullPath; fullName.push_back('/'); fullName.append(dirEntry->d_name); struct stat statResult; if(stat(fullName.c_str(),&statResult)==0) { if(S_ISDIR(statResult.st_mode)) entryType=1; else if(S_ISREG(statResult.st_mode)) entryType=2; } #endif if(entryType==1) { /* Store a directory name: */ std::string entryName=dirEntry->d_name; entryName.push_back('/'); directories.push_back(entryName); } else if(entryType==2) { /* Check if the file name matches any of the supplied extensions: */ bool passesFilters=true; if(fileNameFilters!=0) { /* Find the file name's extension: */ const char* extPtr=""; for(const char* enPtr=dirEntry->d_name;*enPtr!='\0';++enPtr) if(*enPtr=='.') extPtr=enPtr; /* Match against the list of allowed extensions: */ passesFilters=false; const char* filterPtr=fileNameFilters; while(*filterPtr!='\0'&&!passesFilters) { /* Extract the next extension: */ const char* extStart=filterPtr; for(;*filterPtr!='\0'&&*filterPtr!=';';++filterPtr) ; /* See if it matches: */ passesFilters=int(strlen(extPtr))==filterPtr-extStart&&memcmp(extPtr,extStart,filterPtr-extStart)==0; /* Skip the separator: */ if(*filterPtr==';') ++filterPtr; } } if(passesFilters) { /* Store a file name: */ std::string entryName=dirEntry->d_name; files.push_back(entryName); } } } } if(pipe!=0) { /* Send a success code to the slave nodes: */ pipe->write<int>(1); } /* Sort the directory and file names separately: */ StringCompare sc; std::sort(directories.begin(),directories.end(),sc); std::sort(files.begin(),files.end(),sc); if(pipe!=0) { /* Send the directory names to the slave nodes: */ for(std::vector<std::string>::const_iterator dIt=directories.begin();dIt!=directories.end();++dIt) { /* Write the string: */ pipe->write<int>(dIt->size()); pipe->write<char>(dIt->c_str(),dIt->size()+1); } /* Send the file names to the slave nodes: */ for(std::vector<std::string>::const_iterator fIt=files.begin();fIt!=files.end();++fIt) { /* Write the string: */ pipe->write<int>(fIt->size()); pipe->write<char>(fIt->c_str(),fIt->size()+1); } /* Send the list terminator message: */ pipe->write<int>(-1); pipe->finishMessage(); } /* Copy all names into the list box: */ fileList->getListBox()->clear(); for(std::vector<std::string>::const_iterator dIt=directories.begin();dIt!=directories.end();++dIt) fileList->getListBox()->addItem(dIt->c_str()); for(std::vector<std::string>::const_iterator fIt=files.begin();fIt!=files.end();++fIt) fileList->getListBox()->addItem(fIt->c_str()); } else { /* Read the status flag from the master node: */ int success=pipe->read<int>(); if(success) { /* Clear the list box: */ fileList->getListBox()->clear(); /* Read the directory and file names: */ int length; int bufferSize=128; char* buffer=new char[bufferSize]; while((length=pipe->read<int>())>=0) { /* Make sure the buffer is big enough: */ if(bufferSize<length+1) { delete[] buffer; bufferSize=(length+1)*3/2; buffer=new char[bufferSize]; } /* Read the string and add it to the list box: */ pipe->read<char>(buffer,length+1); fileList->getListBox()->addItem(buffer); } delete[] buffer; } else return false; } return true; }