void FileMonitor::adopt(const ibrcommon::File &path) { // look for ".dtndrive" file const ibrcommon::File drivefile = path.get(".dtndrive"); if (drivefile.exists()) { ibrcommon::ConfigFile cf(drivefile.getPath()); try { const dtn::data::EID eid( cf.read<std::string>("EID") ); dtn::core::Node n(eid); const std::string uri = "file://" + path.getPath() + "/" + cf.read<std::string>("PATH"); n.add(dtn::core::Node::URI(dtn::core::Node::NODE_DISCOVERED, dtn::core::Node::CONN_FILE, uri, 0, 10)); dtn::core::BundleCore::getInstance().getConnectionManager().add(n); _active_paths[path] = n; IBRCOMMON_LOGGER_DEBUG_TAG("FileMonitor", 5) << "Node on drive found: " << n.getEID().getString() << IBRCOMMON_LOGGER_ENDL; } catch (const ibrcommon::ConfigFile::key_not_found&) {}; } }
int init(int argc, char** argv) { int index; int c; opterr = 0; while ((c = getopt (argc, argv, "w:")) != -1) switch (c) { case 'w': blob_path = ibrcommon::File(optarg); break; case '?': if (optopt == 'w') fprintf (stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 1; default: print_help(); abort(); break; } int optindex = 0; for (index = optind; index < argc; index++) { switch (optindex) { case 0: _appname = std::string(argv[index]); break; case 1: _shell = std::string(argv[index]); break; case 2: _script = std::string(argv[index]); break; } optindex++; } // print help if not enough parameters are set if (optindex < 2) { print_help(); exit(0); } // enable file based BLOBs if a correct path is set if (blob_path.exists()) { ibrcommon::BLOB::changeProvider(new ibrcommon::FileBLOBProvider(blob_path)); } return 0; }