void Graphical_UI::saveIndividual() { QString tmpfilename(filename); tmpfilename.remove(".pcd", Qt::CaseInsensitive); tmpfilename.remove(".ply", Qt::CaseInsensitive); tmpfilename = QFileDialog::getSaveFileName(this, "Save point cloud to one file per node", tmpfilename, tr("PCD (*.pcd)")); tmpfilename.remove(".pcd", Qt::CaseInsensitive); Q_EMIT saveIndividualClouds(tmpfilename); QString message = tr("Saving Model Node-Wise"); statusBar()->showMessage(message); //infoLabel->setText(message); }
int main(int argc, char* argv[]) { try { log_init(); cxxtools::Arg<const char*> tmpfilename(argc, argv, 't', "zimindexer.tmp"); cxxtools::Arg<const char*> trivialWordsFile(argc, argv, 'T'); cxxtools::Arg<unsigned> memoryFactor(argc, argv, 'M', 64); zim::writer::ZimCreator creator(argc, argv); zim::writer::Indexer indexer(tmpfilename, trivialWordsFile, memoryFactor); if (argc != 3) { std::cout << "usage: " << argv[0] << " [options] zim-file index-filename\n" "options:\n" "\t-s <number> specify chunk size for compression in kB (default 1024)\n" "\t-T <file> trivial words file for full text index (a text file with words, which are not indexed)\n" "\t-M <number> memory factor (default 64, smaller factors reduce memory usage but makes indexer slower,\n" "\t try smaller values when you run out of memory)\n" "\t-t <filename> temporary file name (default zimindexer.tmp)\n"; return -1; } const char* sourcefile = argv[1]; const char* outfile = argv[2]; indexer.setFilename(outfile); indexer.createIndex(sourcefile); creator.create(outfile, indexer); } catch (const std::exception& e) { log_fatal(e.what()); std::cerr << e.what() << std::endl; } }
int delete_old_junk(char *filename) { struct fileheader fhdr; char tmpfile[STRLEN], deleted[STRLEN]; int fdr, fdw; int count, mday, fmday, total, ndeleted; time_t now; struct stat statbuf; int normalboard; if (stat(filename, &statbuf)) { if (errno == ENOENT) return 0; return -1; } total = statbuf.st_size / sizeof (fhdr); time(&now); mday = now / (3600 * 24) % 100; tmpfilename(filename, tmpfile, deleted); if (digestmode == 4 || digestmode == 5) { tmpfile[strlen(tmpfile) - 1] = (digestmode == 4) ? 'D' : 'J'; deleted[strlen(deleted) - 1] = (digestmode == 4) ? 'D' : 'J'; } if ((fdr = open(filename, O_RDONLY, 0)) == -1) { if (errno == ENOENT) return 0; return -2; } ndeleted = 0; while (read(fdr, &fhdr, sizeof (fhdr)) == sizeof (fhdr)) { fmday = fhdr.deltime; while (fmday > mday) fmday -= 100; if (fhdr.accessed & FH_MARKED || mday - fmday < 30) continue; ndeleted++; break; } if (ndeleted == 0) { close(fdr); return 0; } if (lseek(fdr, 0, SEEK_SET) < 0) { close(fdr); return -3; } if ((fdw = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0660)) == -1) { close(fdr); return -4; } flock(fdw, LOCK_EX); count = 1; ndeleted = 0; normalboard = strcmp(currboard, "allarticle"); while (read(fdr, &fhdr, sizeof (fhdr)) == sizeof (fhdr)) { char fullpath[STRLEN]; sprintf(fullpath, MY_BBS_HOME "/boards/%s/%s", currboard, fh2fname(&fhdr)); fmday = fhdr.deltime; while (fmday > mday) fmday -= 100; if (fhdr.accessed & FH_MARKED || ((mday - fmday < 30 && normalboard) || (mday - fmday < 2 && !normalboard))) { while (mday - fmday > 3 && mday - fmday < 7 && fhdr.accessed & FH_ATTACHED) { struct stat st; if (lstat(fullpath, &st) < 0) break; if (S_ISLNK(st.st_mode) || st.st_nlink > 1) break; filter_attach(fullpath); fhdr.accessed &= ~FH_ATTACHED; break; } if ((safewrite(fdw, &fhdr, sizeof (fhdr)) == -1)) { unlink(tmpfile); flock(fdw, LOCK_UN); close(fdw); close(fdr); return -5; } } else { // char fullpath[STRLEN]; // sprintf(fullpath,"/home/bbs/boards/%s/%s",currboard,fh2fname(&fhdr)); //printf("%d %d %s\n", count, (int)fhdr.accessed, fullpath); // unlink(fullpath); if (!normalboard) { unlink(fullpath); } ndeleted++; } count++; } close(fdr); if (rename(filename, deleted) == -1) { flock(fdw, LOCK_UN); close(fdw); return -6; } if (rename(tmpfile, filename) == -1) { flock(fdw, LOCK_UN); close(fdw); return -7; } flock(fdw, LOCK_UN); close(fdw); printf("%d %d ", count, ndeleted); return 0; }
status_t RunPipedCommand(const char *cmdstr, BString &out, bool redirectStdErr) { if (!cmdstr) return B_BAD_DATA; BString command(cmdstr); out = ""; if (gUsePipeHack) { BString tmpfilename("/tmp/Paladin.build.tmp."); tmpfilename << real_time_clock_usecs(); command << " > " << tmpfilename; if (redirectStdErr) command << " 2>&1"; system(command.String()); BFile file(tmpfilename.String(), B_READ_ONLY); if (file.InitCheck() != B_OK) { STRACE(1,("Couldn't make temporary file for RunPipedCommand(\"%s\")\n", command.String())); return file.InitCheck(); } // char buffer[1024]; // while (file.Read(buffer, 1024) > 0) // out << buffer; off_t fileSize; file.GetSize(&fileSize); char buffer[1028]; while (fileSize > 0) { size_t bytesRead = file.Read(buffer, fileSize > 1024 ? 1024 : fileSize); if (bytesRead <= 1024) buffer[bytesRead] = '\0'; out << buffer; fileSize -= bytesRead; } file.Unset(); BEntry(tmpfilename.String()).Remove(); } else { if (redirectStdErr) command << " 2>&1"; FILE *fd = popen(cmdstr,"r"); if (!fd) { STRACE(1,("Bailed out on RunPipedCommand(\"%s\"): NULL pipe descriptor\n", command.String())); return B_BUSTED_PIPE; } char buffer[1024]; BString errmsg; while (fgets(buffer,1024,fd)) out += buffer; pclose(fd); } return B_OK; }