void HttpDownload::slot_extractionDone() { // Set status status = "downloading"; // Continue with downloading getNextFile(); }
bool fileFinder::init(const char* basepath) { clear(); m_hasFile = false; rellen = strlen(basepath)+3; relpath = new char[rellen]; strcpy(relpath, basepath); return getNextFile(true); } // bool fileFinder::init(const char* basepath)
bool DirReader::getNextFile() { if (directory) { file = readdir(directory); if (getFileName() != "" && matchExtension(getFileName())) return (true); else if (file) return (getNextFile()); } return (false); }
char* fileFinder::nextfile() { if (m_hasFile) { strcpy(filename, fileData.cFileName); strcpy(currentPath, relpath); } else { strcpy(filename, ""); }; m_hasFile = false; getNextFile(false); return filename; } // char* fileFinder::nextfile()
void GmZipWriter::createNewZipFile () { flush (); wxString nextFile = getNextFile (); _pWriter->Rename (nextFile); _pWriter->Rebind (_pZipFile->m_szFileName, wxFile::write_append); ++_stZipStat.uiArchive; _stZipStat.ui64Position = 0; GmZipWriter::curEntries = 0;//reset. return; }
void HttpDownload::slot_verificationDone() { // Calculate remaing files filesLeft = fileList.size(); for(int i = 0; i < fileListSize.size(); i++) { totalSizeDownload += fileListSize.at(i).toInt(); } // Set status status = "downloading"; // Get the next file getNextFile(); }
void ImageFrame::keyPressEvent ( QKeyEvent * event ){ if(event->key() == Qt::Key_Up){ QFileInfo fi = getNextFile(filename); if(!fi.fileName().isEmpty()){ setTitle(fi.fileName()); filename = fi.absoluteFilePath(); imageLoadingTimer->start(200); } } if(event->key() == Qt::Key_Down){ QFileInfo fi = getPreviousFile(filename); if(!fi.fileName().isEmpty()){ setTitle(fi.fileName()); filename = fi.absoluteFilePath(); imageLoadingTimer->start(200); } } }
void HttpDownload::slot_extractionDone(bool _extractionState) { // Check extraction state if(!_extractionState) { QMessageBox::information(0, "Extraction error!", "There was an error while extracting, please contact the support!"); } else { extractionState = true; } // Set status status = "downloading"; // Continue with downloading getNextFile(); }
/* Get next image, and return, or return NULL */ ILubyte * GetNextImage(void) { char *nextFile; // setup source directory char path[200]; strcpy (path, directory); // read while the file not .jpg and there are still files while ((nextFile = getNextFile()) && !(strstr(nextFile, ".jpg") > 0)) { printf("Skipping invalid file: %s\n", nextFile); } if (nextFile) { //ilInit(); //ilGenImages(1,&image); //ilBindImage(image); //puts( ep->d_name); strcpy(filename, nextFile); strcat(path, nextFile); //puts(path); printf("Opening %s\n", path); ilLoadImage(path); // get size xsize = ilGetInteger(IL_IMAGE_WIDTH); ysize = ilGetInteger(IL_IMAGE_HEIGHT); fprintf(stdout, "image size (x,y) = (%d,%d)\n", xsize, ysize); //ilLoadImage("C:\\Documents and Settings\\Administrator\\Desktop\\carpark - AR\\carpark - AR 001.JPG"); //bind .jpeg function to image ilConvertImage( IL_BGRA, IL_UNSIGNED_BYTE); //convert to ARUint8 return(ilGetData()); } else if (loopImages == 1) { dp = opendir (directory); } return NULL; }
void AssetBrowser::processDir(const char* dir, int base_length) { auto* iter = PlatformInterface::createFileIterator(dir, m_editor.getAllocator()); PlatformInterface::FileInfo info; while (getNextFile(iter, &info)) { if (info.filename[0] == '.') continue; if (info.is_directory) { char child_path[Lumix::MAX_PATH_LENGTH]; Lumix::copyString(child_path, dir); Lumix::catString(child_path, "/"); Lumix::catString(child_path, info.filename); processDir(child_path, base_length); } else { addResource(dir + base_length, info.filename); } } destroyFileIterator(iter); }
void DirReader::genList() { list.clear(); while (getNextFile()) list.push_back(getFileName()); }
void HttpDownload::slot_downloadFinished(QNetworkReply *reply) { /** * @brief The file name */ QString fileName; /** * @brief Flag for extraction */ bool needsExtraction = false; // Check in which download phase we are switch(downloadPhase) { case 0: fileName = "launcher/downloads/files_game.txt"; break; case 1: fileName = fileList.at(filesLeft); break; } // Open the file to write to QFile file(installationPath + fileName); if(file.open(QIODevice::WriteOnly)) { // Open a stream to write into the file QDataStream stream(&file); // Get the size of the file int size = reply->size(); // Add size to status int for displaying totalSizeDownloadedCurrent = qint64(0); totalSizeDownloaded += qint64(size); // Get the data of the file QByteArray temp = reply->readAll(); // Write the file stream.writeRawData(temp, size); // Set exe permissions file.setPermissions(QFile::ExeUser | QFile::ExeGroup | QFile::ExeOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOwner | QFile::ReadUser); // Close the file file.close(); // Check if it is an archive if(fileName.endsWith("tar.xz")) { // Create instance of archiver archive->setFile(installationPath + fileName, installationPath); // Connect as start as thread connect(archive, SIGNAL(finished()),SLOT(slot_extractionDone())); archive->start(); // Set flag and status needsExtraction = true; status = "extracting"; } } // If phase 0 take future steps if(!needsExtraction) { switch(downloadPhase) { case 0: prepareDownload(); downloadPhase = 1; break; case 1: getNextFile(); break; } } }
void HttpDownload::slot_downloadFinished(QNetworkReply *reply) { /** * @brief The file name */ QString fileName; /** * @brief Flag for extraction */ bool needsExtraction = false; // Check in which download phase we are switch(downloadPhase) { case 0: fileName = "launcher/downloads/files_game.txt"; break; case 1: fileName = fileList.at(filesLeft); break; } Logging::addEntry(LOG_LEVEL_INF, "Savinge file: " + fileName, FUNCTION_NAME); // Open the file to write to QFile file(installationPath + fileName); if(file.open(QIODevice::WriteOnly)) { // Open a stream to write into the file QDataStream stream(&file); // Get the size of the file qint64 size = reply->size(); // Add size to status int for displaying totalSizeDownloadedCurrent = qint64(0); totalSizeDownloaded += qint64(size); // Get the data of the file QByteArray temp = reply->read(size); // Note: ReadAll will crash 32 bit builds! // Write the file stream.writeRawData(temp, size); // Set exe permissions file.setPermissions(QFile::ExeUser | QFile::ExeGroup | QFile::ExeOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOwner | QFile::ReadUser); // Close the file file.close(); // Check if it is an archive if(fileName.endsWith("xz")) { Logging::addEntry(LOG_LEVEL_INF, "Found archive, starting extracting", FUNCTION_NAME); // Get folder structure QStringList extractFolders = fileName.split("/"); QString extractFolder; for(int i = 0; i < extractFolders.size()-1; i++) { extractFolder += extractFolders.at(i) + "/"; } // Create sub folder to extract into QString targetFolder = extractFolders.last().split(".").at(0); QDir().mkdir(installationPath + extractFolder + targetFolder); // Create instance of archiver archive->setFile(extractFolders.last(), installationPath + extractFolder, targetFolder); // Connect as start as thread connect(archive, SIGNAL(extraction_done(bool)),SLOT(slot_extractionDone(bool))); archive->start(); // Set flag and status needsExtraction = true; status = "extracting"; } } else { Logging::addEntry(LOG_LEVEL_ERR, "File could not be opened", FUNCTION_NAME); } // If phase 0 take future steps if(!needsExtraction) { switch(downloadPhase) { case 0: prepareDownload(); downloadPhase = 1; break; case 1: getNextFile(); break; } } }
TitleList *getUpdateCIAs() { Handle dir, CIAFile; FS_DirectoryEntry ent; int ret; int ciafiles; TitleList *updateCIAs; char ciaPath[9 + 16 + 4 + 1]; // /updates/ + 16 hex digits + .cia + \0 LOG_INFO("getUpdateCIAs"); // Run through first and count .cia files. dir = openDirectory(CIAS_PATH); if(dir == 0) { LOG_ERROR("getUpdateCIAs: Failed to open SDMC:" CIAS_PATH ".\n"); printf("Failed to open SDMC:" CIAS_PATH ".\n"); goto error0; } ciafiles = 0; for(;;) { ret = getNextFile(dir, &ent); if(ret < 1) { if(ret == -1) { LOG_ERROR("getUpdateCIAs: Error reading directory."); printf("Error reading directory.\n"); goto error2; } break; } simpleUTF16toASCII((char *)(ent.name)); if(isCIAName((char *)(ent.name)) == 1) { ciafiles++; } } closeDirectory(dir); LOG_VERBOSE("Found %d files.", ciafiles); updateCIAs = initTitleList(ciafiles, 0); // Run through a second time and add CIA info. dir = openDirectory(CIAS_PATH); if(dir == 0) { LOG_ERROR("getUpdateCIAs: Failed to open SDMC:" CIAS_PATH ".\n"); printf("Failed to open SDMC:" CIAS_PATH ".\n"); goto error1; } ciafiles = 0; for(;;) { ret = getNextFile(dir, &ent); if(ret < 1) { if(ret == -1) { LOG_ERROR("getUpdateCIAs: Error reading directory."); printf("Error reading directory.\n"); goto error2; } break; } simpleUTF16toASCII((char *)(ent.name)); if(isCIAName((char *)(ent.name)) == 1) { snprintf(ciaPath, 9 + 16 + 4 + 1, CIAS_PATH "%s", ent.name); CIAFile = openFileHandle(ciaPath, FS_OPEN_READ); if(CIAFile == 0) { LOG_ERROR("getUpdateCIAs: Failed to open %s for read.\n", ciaPath); printf("Failed to open %s for read.\n", ciaPath); goto error2; } if(R_FAILED(AM_GetCiaFileInfo(MEDIATYPE_NAND, updateCIAs->title[ciafiles], CIAFile))) { LOG_ERROR("getUpdateCIAs: Failed to get information on %s.\n", ciaPath); printf("Failed to get information on %s.\n", ciaPath); goto error3; } closeFileHandle(CIAFile); ciafiles++; LOG_VERBOSE("getUpdateCIAs: Added %s.", (char *)(ent.name)); } } closeDirectory(dir); LOG_INFO("getUpdateCIAs: Got CIAs from SD card."); return(updateCIAs); error3: closeFileHandle(CIAFile); error2: closeDirectory(dir); error1: freeTitleList(updateCIAs); error0: LOG_ERROR("getUpdateCIAs: Failed to get CIAs from SD card."); return(NULL); }
const std::string LLFilePicker::getFirstFile() { mCurrentFile = 0; return getNextFile(); }
bool OSDir::getNextFile(OSFile &oFile, bool bRecursive) { return getNextFile(oFile, NULL, bRecursive); }
void ShaderCompiler::makeUpToDate() { auto* iter = PlatformInterface::createFileIterator("shaders", m_editor.getAllocator()); Lumix::Array<Lumix::string> src_list(m_editor.getAllocator()); auto& fs = m_editor.getEngine().getFileSystem(); PlatformInterface::FileInfo info; while (getNextFile(iter, &info)) { char basename[Lumix::MAX_PATH_LENGTH]; Lumix::PathUtils::getBasename(basename, sizeof(basename), info.filename); if (!Lumix::PathUtils::hasExtension(info.filename, "shd")) continue; const char* shd_path = StringBuilder<Lumix::MAX_PATH_LENGTH>( "shaders/", info.filename); auto* file = fs.open(fs.getDiskDevice(), shd_path, Lumix::FS::Mode::OPEN_AND_READ); if (!file) { Lumix::g_log_error.log("shader compiler") << "Could not open " << info.filename; continue; } int len = (int)file->size(); Lumix::Array<char> data(m_editor.getAllocator()); data.resize(len+1); file->read(&data[0], len); data[len] = 0; fs.close(*file); Lumix::ShaderCombinations combinations; Lumix::Shader::getShaderCombinations( getRenderer(), &data[0], &combinations); const char* bin_base_path = StringBuilder<Lumix::MAX_PATH_LENGTH>("shaders/compiled/", basename, "_"); if (isChanged(combinations, bin_base_path, shd_path)) { src_list.emplace(shd_path, m_editor.getAllocator()); } } PlatformInterface::destroyFileIterator(iter); for (int i = 0; i < m_dependencies.size(); ++i) { auto& key = m_dependencies.getKey(i); auto& value = m_dependencies.at(i); for (auto& bin : value) { if (!Lumix::fileExists(bin.c_str()) || Lumix::getLastModified(bin.c_str()) < Lumix::getLastModified(key.c_str())) { char basename[Lumix::MAX_PATH_LENGTH]; Lumix::PathUtils::getBasename(basename, sizeof(basename), bin.c_str()); char tmp[Lumix::MAX_PATH_LENGTH]; getSourceFromBinaryBasename(tmp, sizeof(tmp), basename); Lumix::string src(tmp, m_editor.getAllocator()); src_list.push(src); } } } src_list.removeDuplicates(); for (auto src : src_list) { compile(src.c_str()); } }