//recursive functions to list filenames and apply filters. void print_dir_entries(const char *pathname, FILTER *filter, int level) { struct dirent **namelist; int number_of_names; if (level == 0) return; if (level > 0) level--; number_of_names = scandir(pathname, &namelist, 0, alphasort); if (number_of_names < 0) { fprintf(stderr, "scandir process %s error:", pathname); perror(""); } else { while (number_of_names--) { char *entry_name = namelist[number_of_names]->d_name; if (strcmp(entry_name, ".") == 0 || strcmp(entry_name, "..") == 0) { continue; } filter_files(pathname, namelist[number_of_names], filter); if (namelist[number_of_names]->d_type == DT_DIR) { print_dir_entries(normalize_path(pathname, entry_name), filter, level); } free(namelist[number_of_names]); } free(namelist); } }
/* * mark the unnecessary services as finished. * * action is either boot, start or stop. * prev and run are the previous and the next runlevel. */ void check_run_files(const char *action, const char *prev, const char *run) { char buf[4] = "rc0"; if (! strcmp(action, "boot")) { #ifdef SUSE /* SuSE */ filter_files("boot", 'S', 0); } else if (! strcmp(action, "halt")) { filter_files("boot", 'K', 0); } else if (! strcmp(action, "start")) { buf[2] = *prev; filter_files(buf, 'K', 1); buf[2] = *run; filter_files(buf, 'S', 0); } else { buf[2] = *prev; filter_files(buf, 'K', 0); buf[2] = *run; filter_files(buf, 'S', 1); #else /* Debian */ filter_files("rcS", 'S', 0); } else if (! strcmp(action, "start")) {
void Torrent::main_loop() { //qDebug() << "MAIN_LOOP"; if (!isAborted) { std::auto_ptr<libtorrent::alert> a = session.pop_alert(); switch (a->type()) { case libtorrent::add_torrent_alert::alert_type: { filter_files(); break; } // HACER UN FLUSH DESDE ACA CADA VEZ QUE SE DESCARGUEN 2 PIEZAS COMPLETAS. case libtorrent::cache_flushed_alert::alert_type: // No lo toma. { //std::cout << "//// CHACHE_FLUSHED" << std::endl; break; } case libtorrent::file_error_alert::alert_type: case libtorrent::tracker_error_alert::alert_type: case libtorrent::torrent_error_alert::alert_type: { error("ERROR"); break; } default: break; } if (hasMetadata) stats(); QTimer::singleShot(1000, this, SLOT(main_loop())); } }
void torrent_handle::filter_files(std::vector<bool> const& files) const { INVARIANT_CHECK; TORRENT_FORWARD(filter_files(files)); }