void copyFiles(const QStringList &files, const QDir &fromDir, const QDir &toDir, const QString &intendent = " ") { if (intendent.size() > 40) { out << "Infinite loop detected\n"; out.flush(); abort(); } for (const QString &file : files) { if (!silent) { out << intendent << "Copying " << fromDir.absoluteFilePath(file) << " to " << toDir.absoluteFilePath(file) << "...\n"; } if (file.contains('*')) { copyFiles(fromDir.entryList(QStringList() << file, QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs), fromDir, toDir, intendent); } else { if (QFileInfo(fromDir, file).isDir()) { QDir dir(toDir); if (!dir.exists(file)) { if (!dir.mkpath(file)) { abort(); } } dir.cd(file); QDir fDir(fromDir); fDir.cd(file); copyFiles(fDir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs), fDir, dir, intendent + " "); } QFile::copy(fromDir.absoluteFilePath(file), toDir.absoluteFilePath(file)); } } }
int main(int ac, char *av[]) { /* checks args */ if(ac != 3) { fprintf(stderr, "usage: %s source destination\n", *av); exit(1); } char *src = av[1]; char *dest = av[2]; if( src[0] != '/' && dest[0] != '/' )//cp1 file1.txt file2.txt { copyFiles(src, dest); } else if( src[0] != '/' && dest[0] == '/' )//cp1 file1.txt /dir { int i; for(i=1; i<=strlen(dest); i++) { dest[(i-1)] = dest[i]; } strcat(dest, "/"); strcat(dest, src); copyFiles(src, dest); } else if( src[0] == '/' && dest[0] == '/' )//cp1 /dir1 /dir2 { //- copies all regular files from /dir1 to /dir2 int i; for(i=1; i<=strlen(dest); i++) { dest[(i-1)] = dest[i]; } for(i=1; i<=strlen(src); i++) { src[(i-1)] = src[i]; } //printf("COPYING TWO DIRECTORIES:\n"); //printf("SRC is %s, DEST is %s\n", src, dest); copyDir(src, dest); } else { fprintf(stderr, "usage: cp1 source destination\n"); exit(1); } }
PFileMenu::PFileMenu(bool isRoot) : tail(0L), path(QString()), isClean(true), lastActivated(0) { if (!testDir2(KDISKNAV_PERSONAL_DIR)) { // personal dir just created -> add some useful links #ifdef OLD // OLD STYLE (symlinks) ::symlink(QDir::homeDirPath(), (const char*) QString(QDir::homeDirPath() +KDISKNAV_PERSONAL_DIR + "/Home")); ::symlink((const char*)(QDir::homeDirPath() + "/Desktop"), (const char*) QString(QDir::homeDirPath() +KDISKNAV_PERSONAL_DIR + "/Desktop")); #else // NEW STYLE (URL files) QString kdisknav_personaldir = QDir::homeDirPath() +KDISKNAV_PERSONAL_DIR; copyFiles(KApplication::kde_datadir() + "/kpanel/default/Home.kdelnk", kdisknav_personaldir + "/Home.kdelnk"); copyFiles(KApplication::kde_datadir() + "/kpanel/default/Desktop.kdelnk", kdisknav_personaldir + "/Desktop.kdelnk"); /* FILE* fout = ::fopen(kdisknav_personaldir + "/Home.kdelnk", "w"); if (fout != 0L) { ::fprintf(fout, "# KDE Config File\n"); ::fprintf(fout, "[KDE Desktop Entry]\n"); ::fprintf(fout, "MiniIcon=kfm_home.xpm\n"); ::fprintf(fout, "Comment=Personal Files\n"); ::fprintf(fout, "URL=file:$HOME\n"); ::fprintf(fout, "Icon=kfm_home.xpm\n"); ::fprintf(fout, "Type=Link\n"); ::fclose(fout); } fout = ::fopen(kdisknav_personaldir + "/Desktop.kdelnk", "w"); if (fout != 0L) { ::fprintf(fout, "# KDE Config File\n"); ::fprintf(fout, "[KDE Desktop Entry]\n"); ::fprintf(fout, "MiniIcon=desktop_settings.xpm\n"); ::fprintf(fout, "Comment=Your desktop\n"); ::fprintf(fout, "URL=file:$HOME/Desktop\n"); ::fprintf(fout, "Icon=desktop_settings.xpm\n"); ::fprintf(fout, "Type=Link\n"); ::fclose(fout); } */ #endif } if (isRoot) buildRootMenu(); }
void PMenu::copyLnkFiles(QDir base_dir) { PMenuItem *item; for( item = list.first(); item != 0; item = list.next() ) { if( item->entry_type == submenu ) { QDir sub_dir(base_dir); if( item->old_name.isEmpty() ) { if( item->real_name.isEmpty() ) item->real_name = item->text_name; base_dir.mkdir(item->real_name); if( !sub_dir.cd(item->real_name) ) continue; } else { if( !base_dir.exists( item->old_name ) ) { base_dir.mkdir(item->old_name); if( base_dir.exists( item->dir_path + '/' + item->old_name + "/.directory") ) copyFiles( item->dir_path + '/' + item->old_name + "/.directory", base_dir.absPath() + '/' + item->old_name + "/.directory" ); } if( !sub_dir.cd(item->old_name) ) continue; } item->sub_menu->copyLnkFiles( sub_dir ); } } for( item = list.first(); item != 0; item = list.next() ) { if( item->entry_type == separator || item->old_name.isEmpty() ) continue; if( item->entry_type != submenu ) { if( base_dir.exists( item->old_name ) ) continue; else { if( base_dir.exists( item->dir_path + '/' + item->old_name ) ) copyFiles( item->dir_path + '/' + item->old_name, base_dir.absPath() + '/' + item->old_name ); } } } }
void CopyTask::copyDirs( const QString& dirName, const QString& dest ) { qDebug()<<"Copy dir from: "<<dirName<<" dest: "<<dest; QDir dir( dirName ); if( !QDir( dest ).mkdir( dir.dirName() ) ) qDebug()<<"Creating dir"<<dest<<" "<<dir.dirName()<<" failed."; QString ndest; ndest.append( dest ); ndest.append( dir.dirName() ); QStringList dirs = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot ); QString newDest(ndest); newDest.append("/"); QString newFrom(dirName); for( int i = 0; i < dirs.count(); i++ ) { //newDest.append( dirs[i] ); //newDest.append("/"); //if( !QDir( dest ).mkdir( dirs[i] ) ) // qDebug()<<"Creating dir"<<dirs[i]<<" failed."; newFrom.clear(); newFrom.append(dirName); newFrom.append("/"); newFrom.append( dirs[i] ); copyDirs( newFrom, newDest ); } QStringList files = dir.entryList( QDir::Files ); copyFiles( dirName, files, ndest ); }
void FMListView::dropEvent( QDropEvent* e ) { //qDebug()<<"dropEvent"; //qDebug()<< e->mimeData()->urls()[0].toString(); QStringList files; int i; for( i=0; i < e->mimeData()->urls().count(); i++ ) { QString file( e->mimeData()->urls()[i].toString() ); if( file.contains("file:///", Qt::CaseInsensitive )) { #ifdef Q_WS_WIN file.remove( 0, 8 ); #else file.remove( 0, 7 ); #endif files.append( file ); //qDebug()<<file; } } if( i > 0 ) { emit copyFiles( files ); } e->acceptProposedAction(); }
bool SimpleViewer::copySimpleViewer() const { if (d->canceled) return false; d->progressWdg->addedAction(i18n("Copying flash files..."), StartingMessage); // Due to its license, simpleviewer is installed in $KDEHOME QDir dir; dir.setPath(d->dataDir); qCDebug(KIPIPLUGINS_LOG) << "Data dir is " << d->dataDir; QStringList files; QStringList entries = dir.entryList(QDir::Files); qCDebug(KIPIPLUGINS_LOG) << "Files to copy " << entries; for (QStringList::ConstIterator it = entries.constBegin(); it != entries.constEnd(); ++it) { files.append(dir.absolutePath() + QLatin1Char('/') + *it); } if (!copyFiles(files, d->tempDir->path())) return false; d->progressWdg->addedAction(i18n("Flash files copied..."), SuccessMessage); return true; }
void ChangeDirThread::run() { if (!m_pUser) { gcException gce(ERR_NULLHANDLE, "User Core is null!"); onErrorEvent(gce); onCompleteEvent(); return; } UTIL::FS::recMakeFolder(m_szDest); if (!UTIL::FS::isValidFolder(m_szDest)) { gcException gce(ERR_BADPATH, "Could not create destination folder"); onErrorEvent(gce); onCompleteEvent(); return; } FileList vFileList; updateDb(vFileList); copyFiles(vFileList); if (!m_bStopped) { m_bCompleted = true; } onCompleteEvent(); }
void ControlPanel::cpButtonClicked( bool /*checked*/ ) { movie->start(); if( leftPanel->lastFocus() > rightPanel->lastFocus() ) { QStringList list = leftPanel->selectedFiles(); //qDebug()<<list; if( list.count() > 0 ) copyFiles( list, rightPanel->curDir(), true ); } else { QStringList list = rightPanel->selectedFiles(); //qDebug()<<list; if( list.count() > 0 ) copyFiles( list, leftPanel->curDir(), false ); } }
bool PanoLastPage::validatePage() { if (d->copyDone) return true; setComplete(false); copyFiles(); return false; }
bool UpdateClient::copyFiles(const QDir &srcDir, const QDir &destDir) { bool withoutErrors = true; if (!srcDir.exists()) return false; // list all directories QStringList entries = srcDir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files); QQueue<FileToCopyInfo> files; foreach (QString entry, entries) { QFileInfo entryInfo(QString("%1/%2").arg(srcDir.path()).arg(entry)); if (entryInfo.isSymLink()) continue; if (entryInfo.isDir()) { QDir nextSrcDir(srcDir); QDir nextDestDir(destDir); //change directory deeper nextSrcDir.cd(entryInfo.fileName()); //if can't change destination directory (probably doesn't exists) if (!nextDestDir.cd(entryInfo.fileName())) { // create directory nextDestDir.mkpath(entryInfo.fileName()); //try change directory if (!nextDestDir.cd(entryInfo.fileName())) { //stop copy and return return false; } } // go deeper withoutErrors &= copyFiles(nextSrcDir, nextDestDir); } else { FileToCopyInfo fileInfo; fileInfo.srcDir = srcDir.path(); fileInfo.destDir = destDir.path(); fileInfo.fileName = entryInfo.fileName(); files.enqueue(fileInfo); } }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { gDebug = (getenv("ANDROID_SDKMAN_DEBUG") != NULL); PVOID oldWow64Value = disableWow64FsRedirection(); CPath javaPath; if (!findJavaInEnvPath(&javaPath) && !findJavaInRegistry(&javaPath) && !findJavaInProgramFiles(&javaPath)) { msgBox("Failed to find Java on your system. Please reinstall it."); return 2; } _ASSERT(!javaPath.isEmpty()); revertWow64FsRedirection(oldWow64Value); // For debugging it's convenient to override the tools directory location CPath toolsDir(getenv("ANDROID_SDKMAN_TOOLS_DIR")); if (toolsDir.isEmpty()) { if (!getModuleDir(&toolsDir)) { displayLastError("Failed to get program's filename: "); return 1; } } _ASSERT(!toolsDir.isEmpty()); CPath tmpDir; if (!mkTempDir("temp-android-tool", &tmpDir)) { return 1; } _ASSERT(!tmpDir.isEmpty()); if (!mkDirs(tmpDir.cstr(), sMkDirList)) { return 1; } if (!copyFiles(toolsDir.cstr(), tmpDir.cstr(), sFilesToCopy)) { return 1; } if (!execSdkManager(javaPath.cstr(), toolsDir.cstr(), tmpDir.cstr(), lpCmdLine)) { displayLastError("Failed to start SDK Manager: "); return 1; } return 0; }
int copyDir(char *source, char *destination) { DIR *dir_ptr = NULL; struct dirent *direntp; char tempDest[strlen(destination)+1]; char tempSrc[strlen(source)+1]; strcat(destination, "/"); strcat(source, "/"); strcpy(tempDest, destination); strcpy(tempSrc, source); //char *fileN; struct stat fileinfo; //printf("RIGHT BEFORE COPYING FILES in copyDir()\n"); //printf("before strcat tempDest=%s\n", tempDest); if( (dir_ptr = opendir(source)) == NULL ) { fprintf(stderr, "cp1: cannot open %s for copying\n", source); return 0; } else { while( (direntp = readdir(dir_ptr))) { //printf("direntp DNAME is %s\n", direntp->d_name); //fileN = direntp->d_name; //printf("File name before Reg Check is %s\n", fileN); if(dostat(direntp->d_name)) { strcat(tempDest, direntp->d_name); //printf("after strcat tempDest=%s\n", tempDest); strcat(tempSrc, direntp->d_name); copyFiles(tempSrc, tempDest); strcpy(tempDest, destination); strcpy(tempSrc, source); } } closedir(dir_ptr); return 1; } }
void CopyApp::doUpdate() { static int partial = 0; if(partial == 0) { if(!checkPermissions(destination)) { startAsSudo(); QApplication::quit(); return; } } partial += 500; if(timeToWait != 0) { ui->progressBar->setValue(partial * 100 / timeToWait); if(partial < timeToWait) { QTimer::singleShot(500, this, SLOT(doUpdate())); return; } } emit currentOperation(tr("Looking for local file list info")); QStringList destinationFileList = processFileList(destination); emit currentOperation(tr("Looking for remote file list info")); QStringList remoteFileList = processFileList(origin); if(destinationFileList.isEmpty() || remoteFileList.isEmpty()) return; emit currentOperation(tr("Deleting old files...")); bool result = true; result &= deleteFiles(destinationFileList, destination); emit currentOperation(tr("Copying new files...")); result &= copyFiles(remoteFileList, origin, destination); QString resultStr; if(result) resultStr = tr("Update finished successfully. "); else resultStr = tr("Update finished with errors. "); if(!appToRun.isEmpty()) resultStr = resultStr + tr("Click ok to restart application"); QMessageBox::information(this, tr("Update finished"), resultStr); if(!appToRun.isEmpty()) { #ifdef Q_OS_OSX QProcess::startDetached("open", QStringList() << QDir(destination).filePath(appToRun)); #else QProcess::startDetached(QDir(destination).filePath(appToRun)); #endif } QApplication::quit(); }
void Directory::doDirTree(const QString &fromPath, const QString &toPath, const QStringList &nameFilters, bool overWrite, QStringList &findFiles, bool isFind) { QQueue<QString> from_all_dirs; QQueue<QString> to_all_dirs; QDir find_in_dir; QStringList file_list; QStringList dir_list; QString current_from_path; QString current_to_path; from_all_dirs.push_back(fromPath); to_all_dirs.push_back(toPath); while(from_all_dirs.size() > 0) { current_from_path = from_all_dirs.head(); current_to_path = to_all_dirs.head(); find_in_dir.setPath(current_from_path); file_list = find_in_dir.entryList(nameFilters, QDir::Files); for (int i = 0; i < file_list.size(); i++) { file_list[i] = formatPath(current_from_path) + file_list[i]; } if (isFind) { findFiles += file_list; }else { copyFiles(file_list, current_to_path, overWrite); } dir_list = find_in_dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); for (int i = 0; i < dir_list.size(); i++) { from_all_dirs += formatPath(current_from_path) + dir_list[i]; to_all_dirs += formatPath(current_to_path) + dir_list[i]; } from_all_dirs.pop_front(); to_all_dirs.pop_front(); } }
bool ProjectManager::copyFiles(const QString& src, const QString& dst) { QFileInfo srcFileInfo(src); if (srcFileInfo.isDir()) { QDir targetDir(dst); targetDir.cdUp(); if (!targetDir.mkdir(QFileInfo(dst).fileName())) return false; QDir sourceDir(src); QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); foreach (const QString &fileName, fileNames) { LOG(INFO) << "Copying file " << fileName.toUtf8().constData(); const QString newSrcFilePath = src + QLatin1Char('/') + fileName; const QString newTgtFilePath = dst + QLatin1Char('/') + fileName; if (!copyFiles(newSrcFilePath, newTgtFilePath)) return false; }
void CopyTask::run() { switch( copyMode ) { case File : { copyFile( srcFile, destination); break; } case List : { copyFiles( srcList, destination ); break; } case Dir : { copyDirs( srcDir, destination ); break; } } }
QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessage) { const QStringList directories = installDirectories(qtInstallData); // Try to find a writable directory. foreach (const QString &directory, directories) { if (!mkpath(directory, errorMessage)) continue; errorMessage->clear(); if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) { errorMessage->clear(); return directory; } } *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", "QMLObserver could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); }
int processFolder(UTIL::FS::Path src, UTIL::FS::Path dest, F shouldConvertFn) { std::vector<UTIL::FS::Path> files; std::vector<UTIL::FS::Path> folders; std::vector<UTIL::FS::Path> destfolders; UTIL::FS::getAllFiles(src, files, NULL); UTIL::FS::getAllFolders(src, folders); UTIL::FS::recMakeFolder(dest); int res = copyFiles(files, dest, shouldConvertFn); if (res != 0) return res; size_t size = filterFolders(folders, destfolders, dest, shouldConvertFn); for (size_t x=0; x<size; x++) { for (size_t y=x+1; y<size; y++) { if (destfolders[x].getLastFolder() == destfolders[y].getLastFolder()) { printf("Cannot copy folder %s as duplicate has been found. Please check that a filter folder of same name doesnt exist.\n", destfolders[x].getLastFolder().c_str()); return -3; } } } for (size_t x=0; x<size; x++) { res = processFolder(folders[x], destfolders[x], shouldConvertFn); if (res != 0) return res; } return 0; }
void UpgradeMessage::convert034 () { // get all chart paths QStringList symbolList; Config config; QString dataPath; config.getData(Config::DataPath, dataPath); int t = dataPath.find("/data1/", 0, TRUE); dataPath.replace(t + 5, 1, "0"); Traverse trav(Traverse::File); trav.traverse(dataPath); trav.getList(symbolList); QString s; config.getData(Config::IndexPath, s); index.open(s); int loop; for (loop = 0; loop < (int) symbolList.count(); loop++) { progBar->setProgress(loop, (int) symbolList.count()); if (createDir(symbolList[loop])) continue; qDebug("Converting %s", symbolList[loop].latin1()); if (createChart(symbolList[loop])) continue; } index.close(); copyFiles(); progBar->setProgress((int) symbolList.count(), (int) symbolList.count()); qDebug("Conversion complete"); }
QString QmlDebuggingLibrary::copy(const QString &qtInstallData, QString *errorMessage) { const QStringList directories = QmlDebuggingLibrary::installDirectories(qtInstallData); // Try to find a writeable directory. foreach (const QString &directory, directories) { if (!mkpath(directory, errorMessage)) { continue; } else { errorMessage->clear(); } if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) { errorMessage->clear(); return directory; } } *errorMessage = QCoreApplication::translate("Qt4ProjectManager::QmlDebuggingLibrary", "QML Debugging library could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); }
static void concatenateBSFiles(int processes, char fileName[1024]) { if(processID == 0) { int i; FILE *destination = myfopen(fileName, "w"), *source = (FILE*)NULL; char sourceName[1024]; strcpy(sourceName, fileName); strcat(sourceName, ".PID."); for(i = 0; i < processes; i++) { char buf[64], temporary[1024]; sprintf(buf, "%d", i); strcpy(temporary, sourceName); strcat(temporary, buf); source = myfopen(temporary, "r"); copyFiles(source, destination); fclose(source); } fclose(destination); } }
size_t copyFiles(std::string sourcepath, std::string destpath, std::string mask, bool case_sensitive, bool rec, bool overwrite) { return copyFiles(toWString(sourcepath, enc_iso8859), toWString(destpath, enc_iso8859), toWString(mask, enc_iso8859), case_sensitive, rec, overwrite); }
int cmd_copy(char *rest) { char **argv, *p; int argc, opts, argi; int freeDestFile = 0; struct CopySource *h; /* Initialize options */ optA = optB = optV = optY = 0; /* read the parameters from env */ if ((argv = scanCmdline(getEnv("COPYCMD"), opt_copy, 0, &argc, &opts)) == 0) return 1; freep(argv); /* ignore any parameter from env var */ if((argv = scanCmdline(rest, opt_copy, 0, &argc, &opts)) == 0) return 1; /* scan the trailing '/a' and '/b' options */ while(argc > 0 && isoption(argv[argc - 1])) { p = argv[--argc]; /* argv[] must not be changed */ if(leadOptions(&p, opt_copy1, 0) != E_None) { freep(argv); return 1; } } initContext(); /* Now parse the remaining arguments into the copy file structure */ for(argi = 0; argi < argc; ++argi) if(isoption(p = argv[argi])) { /* infix /a or /b */ if(leadOptions(&p, opt_copy1, 0) != E_None) { killContext(); freep(argv); return 1; } /* Change the flags of the previous argument */ if(lastApp) lastApp->flags = cpyFlags(); } else { /* real argument */ if(*p == '+') { /* to previous argument */ appendToFile = 1; while(*++p == '+'); if(!*p) continue; } if(!addSource(p)) { killContext(); freep(argv); return 1; } } if(appendToFile) { error_trailing_plus(); killContext(); freep(argv); return 1; } if(!last) { /* Nothing to do */ error_nothing_to_do(); killContext(); freep(argv); return 1; } assert(head); /* Now test if a destination was specified */ if(head != last && !last->app) { /* Yeah */ destFile = dfnexpand(last->fnam, 0); if(!destFile) { error_out_of_memory(); goto errRet; } freeDestFile = 1; h = head; /* remove it from argument list */ while(h->nxt != last) { assert(h->nxt); h = h->nxt; } free(last); (last = h)->nxt = 0; p = strchr(destFile, '\0') - 1; if(*p == '\\' || *p == '/') /* must be a directory */ destIsDir = 1; else destIsDir = dfnstat(destFile) & DFN_DIRECTORY; } else { /* Nay */ destFile = "."; destIsDir = 1; } /* Now copy the files */ h = head; while(copyFiles(h) && (h = h->nxt) != 0); if(freeDestFile) free(destFile); errRet: killContext(); freep(argv); return 0; }
USHORT ECC_FTPGetFileShowStatus(STR *ip,STR *id,STR *pw,STR * Localfilename, STR * Remofilename,BYTE isSSL) { CURL *curl; CURLcode res; double filesize = 0.0; double totaltime = 0.0; BYTE statusline2[64]; struct FtpFile ftpfile={ "tmpfile", /* name to store the file as if succesful */ NULL }; CTOS_LCDSelectMode(d_LCD_TEXT_320x240_MODE); CTOS_LCDGClearCanvas(); ShowTitle(gTransTitle); ShowLine(0,40+16,Big_Font_Size,"資料下載中.",FALSE); ShowLine(0,40+40+16+10,Med_Font_Size,"下載進度",FALSE); curl_global_init(CURL_GLOBAL_DEFAULT); BYTE processstr[32]; curl = curl_easy_init(); if(curl) { BYTE URL[128]; BYTE IDPW[64]; BYTE DNS[64]; BYTE *errstr; memset(URL,0x00,sizeof(URL)); sprintf(URL,"FTPS://%s%s",ip,Remofilename); memset(IDPW,0x00,sizeof(IDPW)); sprintf(IDPW,"%s:%s",id,pw); curl_easy_setopt(curl, CURLOPT_URL,URL); curl_easy_setopt(curl, CURLOPT_USERPWD,IDPW); /* Define our callback to get called when there's data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); BYTE len=sizeof(DNS); USHORT ret = CTOS_EthernetConfigGet(d_ETHERNET_CONFIG_DNSIP, DNS,&len); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 1024L*1000); curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 60); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 60); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60*10); curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, DNS); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); /* Switch on full protocol/debug output */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); if(CURLE_OK != res) { /* we failed */ errstr=(char*)curl_easy_strerror(res); ErrorMessageBox(gTransTitle,"錯誤訊息",errstr,"","",d_MB_CHECK); SystemLog("ECC_FTPGetFile",errstr); return d_Fail; } res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize); if((CURLE_OK == res) && (filesize>0.0)) { sprintf(statusline2,"filesize : %0.0f bytes\n", filesize); ShowLine(0,40+40+40+16+10,Med_Font_Size,statusline2,FALSE); } res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &totaltime); if((CURLE_OK == res) && (totaltime>0.0)) { sprintf(statusline2,"totaltime : %0.0f sec\n", totaltime); ShowLine(0,40+40+40+40+16+10,Med_Font_Size,statusline2,FALSE); } } if(ftpfile.stream) fclose(ftpfile.stream); /* close the local file */ // rename(ftpfile.filename,Localfilename); ULONG lsize=File_GetLen((char *)ftpfile.filename); if(lsize<=0) return d_Fail; remove(Localfilename); int iret= copyFiles((char *)ftpfile.filename, Localfilename); remove(ftpfile.filename); /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); CTOS_Delay(2000); return d_OK; }
ListPanelActions::ListPanelActions(QObject *parent, FileManagerWindow *mainWindow) : ActionsBase(parent, mainWindow) { // set view type QSignalMapper *mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(int)), SLOT(setView(int))); QActionGroup *group = new QActionGroup(this); group->setExclusive(true); QList<KrViewInstance*> views = KrViewFactory::registeredViews(); for(int i = 0; i < views.count(); i++) { KrViewInstance *inst = views[i]; QAction *action = new QAction(QIcon::fromTheme(inst->icon()), inst->description(), group); action->setCheckable(true); connect(action, SIGNAL(triggered()), mapper, SLOT(map())); mapper->setMapping(action, inst->id()); _mainWindow->actions()->addAction("view" + QString::number(i), action); _mainWindow->actions()->setDefaultShortcut(action, inst->shortcut()); setViewActions.insert(inst->id(), action); } // standard actions actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward())); actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward())); //FIXME: second shortcut for up: see actDirUp // KStandardAction::up( this, SLOT( dirUp() ), actionCollection )->setShortcut(Qt::Key_Backspace); /* Shortcut disabled because of the Terminal Emulator bug. */ actDirUp = stdAction(KStandardAction::Up, _func, SLOT(dirUp())); actHome = stdAction(KStandardAction::Home, _func, SLOT(home())); stdAction(KStandardAction::Cut, _func, SLOT(cut())); actCopy = stdAction(KStandardAction::Copy, _func, SLOT(copyToClipboard())); actPaste = stdAction(KStandardAction::Paste, _func, SLOT(pasteFromClipboard())); // Fn keys actF2 = action(i18n("Rename"), 0, Qt::Key_F2, _func, SLOT(rename()) , "F2_Rename"); actF3 = action(i18n("View File"), 0, Qt::Key_F3, _func, SLOT(view()), "F3_View"); actF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit"); actF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy"); actF6 = action(i18n("Move..."), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move"); actShiftF5 = action(i18n("Copy by queue..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesByQueue()) , "F5_Copy_Queue"); actShiftF6 = action(i18n("Move by queue..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesByQueue()) , "F6_Move_Queue"); actF7 = action(i18n("New Directory..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir"); actF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(deleteFiles()) , "F8_Delete"); actF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal"); action(i18n("&New Text File..."), "document-new", Qt::SHIFT + Qt::Key_F4, _func, SLOT(editNew()), "edit_new_file"); action(i18n("F3 View Dialog"), 0, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg"); // file operations action(i18n("Right-click Menu"), 0, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu"); actProperties = action(i18n("&Properties..."), 0, Qt::ALT + Qt::Key_Return, _func, SLOT(properties()), "properties"); actCompDirs = action(i18n("&Compare Directories"), "kr_comparedirs", Qt::ALT + Qt::SHIFT + Qt::Key_C, _gui, SLOT(compareDirs()), "compare dirs"); actCalculate = action(i18n("Calculate &Occupied Space"), "accessories-calculator", 0, _func, SLOT(calcSpace()), "calculate"); actPack = action(i18n("Pac&k..."), "archive-insert", Qt::ALT + Qt::SHIFT + Qt::Key_P, _func, SLOT(pack()), "pack"); actUnpack = action(i18n("&Unpack..."), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_U, _func, SLOT(unpack()), "unpack"); actCreateChecksum = action(i18n("Create Checksum..."), "document-edit-sign", 0, _func, SLOT(createChecksum()), "create checksum"); actMatchChecksum = action(i18n("Verify Checksum..."), "document-edit-decrypt-verify", 0, _func, SLOT(matchChecksum()), "match checksum"); action(i18n("New Symlink..."), 0, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink"); actTest = action(i18n("T&est Archive"), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_E, _func, SLOT(testArchive()), "test archives"); // navigation actRoot = action(i18n("Root"), "folder-red", Qt::CTRL + Qt::Key_Backspace, _func, SLOT(root()), "root"); actCdToOther = action(i18n("Go to Other Panel's Directory"), 0, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel"); action(i18n("&Reload"), "view-refresh", Qt::CTRL + Qt::Key_R, _func, SLOT(refresh()), "std_redisplay"); actCancelRefresh = action(i18n("Cancel Refresh of View"), "dialog-cancel", 0, _gui, SLOT(inlineRefreshCancel()), "cancel refresh"); actFTPNewConnect = action(i18n("New Net &Connection..."), "network-connect", Qt::CTRL + Qt::Key_N, _func, SLOT(newFTPconnection()), "ftp new connection"); actFTPDisconnect = action(i18n("Disconnect &from Net"), "network-disconnect", Qt::SHIFT + Qt::CTRL + Qt::Key_F, _func, SLOT(FTPDisconnect()), "ftp disconnect"); action(i18n("Sync Panels"), 0, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels"); actJumpBack = action(i18n("Jump Back"), "go-jump", Qt::CTRL + Qt::Key_J, _gui, SLOT(jumpBack()), "jump_back"); actSetJumpBack = action(i18n("Set Jump Back Point"), "go-jump-definition", Qt::CTRL + Qt::SHIFT + Qt::Key_J, _gui, SLOT(setJumpBack()), "set_jump_back"); actSyncBrowse = action(i18n("S&ynchron Directory Changes"), "kr_syncbrowse_off", Qt::ALT + Qt::SHIFT + Qt::Key_Y, _gui, SLOT(toggleSyncBrowse()), "sync browse"); actLocationBar = action(i18n("Go to Location Bar"), 0, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar"); toggleAction(i18n("Toggle Popup Panel"), 0, Qt::ALT + Qt::Key_Down, _gui, SLOT(togglePanelPopup()), "toggle popup panel"); action(i18n("Bookmarks"), 0, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks"); action(i18n("Left Bookmarks"), 0, 0, this, SLOT(openLeftBookmarks()), "left bookmarks"); action(i18n("Right Bookmarks"), 0, 0, this, SLOT(openRightBookmarks()), "right bookmarks"); action(i18n("History"), 0, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history"); action(i18n("Left History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history"); action(i18n("Right History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history"); action(i18n("Media"), 0, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media"); action(i18n("Left Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media"); action(i18n("Right Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media"); // and at last we can set the tool-tips actRoot->setToolTip(i18n("ROOT (/)")); actF2->setToolTip(i18n("Rename file, directory, etc.")); actF3->setToolTip(i18n("Open file in viewer.")); actF4->setToolTip("<qt>" + i18n("<p>Edit file.</p>" "<p>The editor can be defined in Konfigurator, " "default is <b>internal editor</b>.</p>") + "</qt>"); actF5->setToolTip(i18n("Copy file from one panel to the other.")); actF6->setToolTip(i18n("Move file from one panel to the other.")); actF7->setToolTip(i18n("Create directory in current panel.")); actF8->setToolTip(i18n("Delete file, directory, etc.")); actF9->setToolTip("<qt>" + i18n("<p>Open terminal in current directory.</p>" "<p>The terminal can be defined in Konfigurator, " "default is <b>konsole</b>.</p>") + "</qt>"); }
//int ftpsget(STR *ip,STR *id,STR *pw,STR * Localfilename, STR * Remofilename,BYTE isSSL) USHORT ECC_FTPGetFile(STR *ip,STR *id,STR *pw,STR * Localfilename, STR * Remofilename,BYTE isSSL) { CURL *curl; CURLcode res; struct FtpFile ftpfile={ "tmpfile", /* name to store the file as if succesful */ NULL }; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { /* * You better replace the URL with one that works! Note that we use an * FTP:// URL with standard explicit FTPS. You can also do FTPS:// URLs if * you want to do the rarer kind of transfers: implicit. */ BYTE URL[128]; BYTE IDPW[64]; BYTE errstr[64]; memset(URL,0x00,sizeof(URL)); sprintf(URL,"FTPS://%s%s",ip,Remofilename); memset(IDPW,0x00,sizeof(IDPW)); sprintf(IDPW,"%s:%s",id,pw); curl_easy_setopt(curl, CURLOPT_URL,URL); curl_easy_setopt(curl, CURLOPT_USERPWD,IDPW); // curl_easy_setopt(curl, d,1); // curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, 1024*1024*2); //curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1024*1024*2); // curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 1024*50); /* Define our callback to get called when there's data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); /* cert is stored PEM coded in file... */ /* since PEM is default, we needn't set it for PEM */ // curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM"); // curl_easy_setopt(curl,CURLOPT_SSLCERT,"CMAS-FTP.pem"); /* if we use a key stored in a crypto engine, we must set the key type to "ENG" */ // curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM"); /* set the private key (file or ID in engine) */ // curl_easy_setopt(curl,CURLOPT_SSLKEY,"CMAS-FTP.pem"); /* set the cert for client authentication */ // curl_easy_setopt(curl,CURLOPT_CAINFO,"CMAS-FTP.pem"); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); // curl_easy_setopt(curl,CURLOPT_SSLCERT,"CMAS-FTP.pem"); /* We activate SSL and we require it for both control and data */ curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); // curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1); // curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION, 1); // curl_easy_setopt(curl, CURLOPT_FTPSSLAUTH,"AUTH TLS"); // curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); /* Switch on full protocol/debug output */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); if(CURLE_OK != res) { /* we failed */ sprintf(errstr, "curl told us %d\n",(int ) res); SystemLog("ECC_FTPGetFile",errstr); return d_Fail; } } if(ftpfile.stream) fclose(ftpfile.stream); /* close the local file */ // rename(ftpfile.filename,Localfilename); ULONG lsize=File_GetLen((char *)ftpfile.filename); if(lsize<=0) return d_Fail; remove(Localfilename); int iret= copyFiles((char *)ftpfile.filename, Localfilename); remove(ftpfile.filename); curl_global_cleanup(); return d_OK; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QStringList args = a.arguments(); if (args.size() < 4) { out << "Usage: " << args[0] << " <version> <qtdir> <platform> [load]\n" << flush; return 1; } const QString version = args[1]; const QDir qtdir = QDir(args[2]); const QString platform = args[3]; if (args.size() > 5) { if (args[4] == "load") { silent = false; } } if (!QRegularExpression("\\d\\.\\d\\.\\d").match(version).hasMatch()) { out << "<version> has to be in the format #.#.#\n" << flush; return 1; } const QString short_version = version.left(3); GetFiles::version = version; // mappings etc. QList<FileGroup> mappings; mappings.append(FileGroup("bin", &GetFiles::binaryFiles)); mappings.append(FileGroup("doc", &GetFiles::docFiles)); mappings.append(FileGroup("examples", &GetFiles::exampleFiles)); mappings.append(FileGroup("imports", &GetFiles::importsFiles)); mappings.append(FileGroup("include", &GetFiles::includeFolders)); mappings.append(FileGroup("lib", &GetFiles::libFiles)); mappings.append(FileGroup("libexec", &GetFiles::libExecFiles)); mappings.append(FileGroup("mkspecs", &GetFiles::mkSpecFiles)); mappings.append(FileGroup("phrasebooks", &GetFiles::phrasebookFiles)); mappings.append(FileGroup("plugins", &GetFiles::pluginNames)); mappings.append(FileGroup("qml", &GetFiles::qmlFiles)); mappings.append(FileGroup("translations", &GetFiles::translationFiles)); QStringList modules; for (const FileGroup &files : mappings) { modules.append((files.fileGetter)().keys()); } modules.removeDuplicates(); out << "Copying files for the following modules: " << modules.join(", ") << "\n" << flush; QDir baseDir; for (const QString &module : modules) { if (baseDir.exists(module + ".tar.gz")) { out << "Skiping already existing module " << module << "\n" << flush; continue; } out << "Copying files for module " << module << "\n" << flush; baseDir.mkdir(module); QDir dir(baseDir); dir.cd(module); for (const FileGroup &files : mappings) { QStringList fs = (files.fileGetter)()[module]; if (fs.isEmpty()) { continue; } out << " Copying " << files.name << " files...\n" << flush; QDir fromDir(qtdir); fromDir.cd(files.name); QDir toDir(dir); toDir.mkdir(files.name); toDir.cd(files.name); copyFiles(fs, fromDir, toDir); } out << " Creating install file for module " << module << "...\n" << flush; { QFile installFile(dir.absoluteFilePath("install.js")); if (!installFile.open(QFile::WriteOnly | QFile::Truncate)) { out << "Error opening install file: " << installFile.errorString() << "\n"; return -1; } QTextStream js(&installFile); js << "FileSystem.mkpath(Paths.installPath);\n"; for (const FileGroup &groups : mappings) { if (groups.fileGetter().contains(module)) { js << "FileSystem.install(\"" << groups.name << "\", Paths.installPath + \"/" << groups.name << "\");\n"; } } js << "\n"; js.flush(); installFile.close(); } out << " Creating removal file for module " << module << "...\n" << flush; { QFile removalFile(dir.absoluteFilePath("remove.js")); if (!removalFile.open(QFile::WriteOnly | QFile::Truncate)) { out << "Error opening remove file: " << removalFile.errorString() << "\n"; return -1; } QTextStream js(&removalFile); for (const FileGroup &group : mappings) { QStringList files = (group.fileGetter)()[module]; for (const QString &file : files) { js << "FileSystem.remove(Paths.installPath + \"/" << group.name << "/" << file << "\");\n"; } } js << "\n"; js.flush(); removalFile.close(); } out << " Creating archive for module " << module << "...\n" << flush; { KArchive *arch = new KTar(baseDir.absoluteFilePath( QString("%1-%2-%3.tar.gz").arg(module, version, platform))); arch->open(QIODevice::ReadWrite); for (const QString &directory : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) { arch->addLocalDirectory(dir.absoluteFilePath(directory), directory); } for (const QString &file : dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) { arch->addLocalFile(dir.absoluteFilePath(file), file); } arch->close(); } } out << "Creating metadata file...\n" << flush; { QFile meta(baseDir.absoluteFilePath("meta.json")); meta.open(QFile::WriteOnly | QFile::Truncate); QMap<QString, QString> descs = GetFiles::descriptions(); QMap<QString, QStringList> deps = GetFiles::dependencies(); QMap<QString, QMap<QString, QStringList>> ndeps = GetFiles::nativeDependencies(); QJsonArray root; for (const QString &module : modules) { QStringList dependencies = deps[module]; dependencies.removeAll(""); dependencies.removeDuplicates(); QMap<QString, QStringList> nDependencies = ndeps[module]; QJsonObject m; m.insert("id", module); m.insert("description", descs[module]); m.insert("version", version); m.insert("platform", platform); m.insert("url", QString("http://localhost/soqute/archives/%1-%2-%3.tar.gz") .arg(module, version, platform)); QJsonArray deps; for (const QString &dep : dependencies) { QJsonObject obj; obj.insert("id", dep); obj.insert("version", version); deps.append(obj); } m.insert("dependencies", deps); QJsonObject nativeDependencies; for (const QString &manager : nDependencies.keys()) { QJsonArray packages = QJsonArray::fromStringList(nDependencies[manager]); nativeDependencies.insert(manager, packages); } m.insert("nativeDependencies", nativeDependencies); root.append(m); } meta.write(QJsonDocument(root).toJson()); } out << "Installing files to server...\n" << flush; { QDir serverRoot("/var/www"); if (!serverRoot.exists("soqute")) { serverRoot.mkdir("soqute"); } serverRoot.cd("soqute"); if (!serverRoot.exists("archives")) { serverRoot.mkdir("archives"); } serverRoot.cd("archives"); for (const QString &archive : baseDir.entryList(QStringList() << "*.tar.gz", QDir::Files)) { out << " Installing " << archive << " to server...\n" << flush; if (serverRoot.exists(archive)) { serverRoot.remove(archive); } QFile::copy(baseDir.absoluteFilePath(archive), serverRoot.absoluteFilePath(archive)); } serverRoot.cdUp(); out << " Installing meta.json to server...\n" << flush; if (serverRoot.exists("meta.json")) { QFile server(serverRoot.absoluteFilePath("meta.json")); Q_ASSERT(server.open(QFile::ReadOnly | QFile::Truncate)); QFile local(baseDir.absoluteFilePath("meta.json")); Q_ASSERT(local.open(QFile::ReadOnly)); QJsonDocument serverDoc = QJsonDocument::fromJson(server.readAll()); server.close(); QJsonArray serverArray = serverDoc.array(); QJsonDocument localDoc = QJsonDocument::fromJson(local.readAll()); local.close(); QJsonArray localArray = localDoc.array(); QVariantList res = serverArray.toVariantList(); res.append(localArray.toVariantList()); Q_ASSERT(server.open(QFile::WriteOnly | QFile::Truncate)); server.write(QJsonDocument(QJsonArray::fromVariantList(res)).toJson()); server.close(); } else { QFile::copy(baseDir.absoluteFilePath("meta.json"), serverRoot.absoluteFilePath("meta.json")); } } out << "Done\n" << flush; return 0; }
void readKeyboard(void) { struct dir_node *currentNode; unsigned char key; bool decision = false; key = toupper(cgetc()); switch((int)key) { case HK_FORMATTER: if(loadOverlay(7)) { formatDisk(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case HK_BASIC_VIEWER: if(loadOverlay(6)) { viewFileAsBASIC(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case HK_HEX_EDIT: if(loadOverlay(5)) { hexEditCurrentFile(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case CH_ENTER: currentNode = getSelectedNode(selectedPanel); if(isDirectory(selectedPanel)) { enterDirectory(selectedPanel); } else if(currentNode != NULL) { sprintf(filePath, "%s/%s", selectedPanel->path, currentNode->name); if(currentNode->type == 0x06 || currentNode->type == 0xFF) { saveScreen(); decision = writeYesNo("Confirm", quit_message, 1); retrieveScreen(); if(decision == true) { exec(filePath, NULL); } } else if(currentNode->type == 0xFC) { if(loadOverlay(6)) { viewFileAsBASIC(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } } else { if(loadOverlay(1)) viewFile(filePath); } } break; case KEY_F4: rereadSelectedPanel(); break; case KEY_F3: selectDrive(selectedPanel); rereadSelectedPanel(); break; case HK_SELECT: selectCurrentFile(); break; #ifdef __APPLE2ENH__ case CH_CURS_UP: #else case CH_CURS_LEFT: #endif moveSelectorUp(selectedPanel); break; #ifdef __APPLE2ENH__ case CH_CURS_DOWN: #else case CH_CURS_RIGHT: #endif moveSelectorDown(selectedPanel); break; #ifdef __APPLE2ENH__ case CH_CURS_LEFT: if(selectedPanel == &rightPanelDrive && strlen(leftPanelDrive.path) > 0) { selectedPanel = &leftPanelDrive; writeSelectorPosition(&leftPanelDrive, '>'); writeSelectorPosition(&rightPanelDrive, ' '); writeCurrentFilename(selectedPanel); } break; case CH_CURS_RIGHT: if(selectedPanel == &leftPanelDrive && strlen(rightPanelDrive.path) > 0) { selectedPanel = &rightPanelDrive; writeSelectorPosition(&leftPanelDrive, ' '); writeSelectorPosition(&rightPanelDrive, '>'); writeCurrentFilename(selectedPanel); } break; #endif case HK_SWITCH_PANEL: if(selectedPanel == &leftPanelDrive && strlen(rightPanelDrive.path) > 0) { selectedPanel = &rightPanelDrive; writeSelectorPosition(&leftPanelDrive, ' '); writeSelectorPosition(&rightPanelDrive, '>'); writeCurrentFilename(selectedPanel); } else if(selectedPanel == &rightPanelDrive && strlen(leftPanelDrive.path) > 0) { selectedPanel = &leftPanelDrive; writeSelectorPosition(&leftPanelDrive, '>'); writeSelectorPosition(&rightPanelDrive, ' '); writeCurrentFilename(selectedPanel); } break; case KEY_SH_PLUS: enterDirectory(selectedPanel); break; case KEY_SH_MINUS: case CH_ESC: leaveDirectory(selectedPanel); break; //case 188: // C= C - Command Menu // writeMenu(command); // break; //case 182: // C= L - Left Menu // writeMenu(left); // break; //case 178: // C= R - Right Menu // writeMenu(right); // break; //case 187: // C= F - File Menu // writeMenu(file); // break; //case 185: // C= O - Options Menu // writeMenu(options); // break; case HK_REREAD_LEFT: rereadDrivePanel(left); break; case HK_REREAD_RIGHT: rereadDrivePanel(right); break; case HK_DRIVE_LEFT: writeDriveSelectionPanel(left); break; case HK_DRIVE_RIGHT: writeDriveSelectionPanel(right); break; case HK_SELECT_ALL: selectAllFiles(selectedPanel, true); break; case HK_DESELECT_ALL: selectAllFiles(selectedPanel, false); break; case KEY_F1: if(loadOverlay(1)) writeHelpPanel(); break; case KEY_F2: quit(); break; case KEY_F5: if(loadOverlay(4)) copyFiles(); break; case HK_RENAME: case KEY_F6: if(loadOverlay(4)) renameFile(); break; case HK_DELETE: case KEY_F8: if(loadOverlay(4)) deleteFiles(); break; //case KEY_AT: // inputCommand(); // break; case KEY_F7: if(loadOverlay(4)) makeDirectory(); break; case HK_TO_TOP: moveTop(selectedPanel); break; case HK_TO_BOTTOM: moveBottom(selectedPanel); break; case HK_PAGE_UP: movePageUp(selectedPanel); break; case HK_PAGE_DOWN: movePageDown(selectedPanel); break; case HK_WRITE_DISK_IMAGE: if(loadOverlay(3)) writeDiskImage(); break; case HK_CREATE_DISK_IMAGE: if(loadOverlay(3)) createDiskImage(); break; case HK_COPY_DISK: if(loadOverlay(2)) copyDisk(); break; default: //writeStatusBarf("%c", key); break; } }
int main() { int menu0ChosenOption = menu0(); while (menu0ChosenOption == 2) { long backupCount = 0; char** backupNames = getBackupList(&backupCount); if (backupCount != 0) { int backupSelected = selectBackup(backupNames, backupCount); char command[MAX_PATH]; sprintf(command,"xcopy /y \"%s\" pad00000.meta",backupNames[backupSelected]); system(command); } else { printf("No backup was found"); } printf("\n"); system("PAUSE"); menu0ChosenOption = menu0(); } if (menu0ChosenOption != EXIT) { int menu1ChosenOption = menu1(); regionSelected = menu1ChosenOption - 1; initProgram(); // This calls the Meta Injector, but it also calls the Meta Patcher inside it, so the whole program runs by this call runMetaInjector(); runMetaPatcher(); displayResults(); int menu2ChosenOption = menu2(); if (menu2ChosenOption == 1) { printf("\nCopying Files..."); copyFiles(FILES_TO_PATCH_FOLDER_NAME,bdoRootFolder); printf("\nDone.\n"); } else if (menu2ChosenOption == 2) { printf("\nMoving Files..."); moveFiles(FILES_TO_PATCH_FOLDER_NAME,bdoRootFolder); printf("\nDone.\n"); } if (menu2ChosenOption != EXIT) { printf("\n"); system("PAUSE"); } } return 0; }