Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); bool exists = f && f->is_open(); String tempFile = get_data_dir(); if (!exists) return FAILED; if (p_path.begins_with("res://")) { if (PackedData::get_singleton()->has_path(p_path)) { print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str()); return ERR_INVALID_PARAMETER; } else { p_path = p_path.replace("res:/", Globals::get_singleton()->get_resource_path()); } } else if (p_path.begins_with("user://")) p_path = p_path.replace("user:/", get_data_dir()); memdelete(f); print("Playing video: %S\n", p_path.c_str()); if (_play_video(p_path, p_volume, p_audio_track, p_subtitle_track)) return OK; return FAILED; }
int main(int argc, char **argv) { int i; reg_func func; sm_outfd = stdout; parse_args(&argc, &argv); /* this gets set back to zero when we parse the first function */ final_pass = 1; data_dir = get_data_dir(argv[0]); allocate_hook_memory(); create_function_hook_hash(); open_smatch_db(); for (i = 1; i < ARRAY_SIZE(reg_funcs); i++) { func = reg_funcs[i].func; /* The script IDs start at 1. 0 is used for internal stuff. */ if (!option_enable || reg_funcs[i].enabled || !strncmp(reg_funcs[i].name, "register_", 9)) func(i); } smatch(argc, argv); free_string(data_dir); return 0; }
std::string get_value_of(BuildConfigParam p) { switch (p) { case build_config_param_DataDir: return get_data_dir(); } throw std::runtime_error("Unexpected parameter"); }
void data_file_handler::parse_for_data_files(std::string dir, std::list<std::string>& idlist) { directory d(get_data_dir() + dir); for (std::string f = d.read(); !f.empty(); f = d.read()) { if (f[0] == '.' || f == "CVS") { // avoid . and .. entries, as well as hidden files, and CVS directories as well continue; } else if (is_directory(get_data_dir() + dir + f)) { parse_for_data_files(dir + f + "/", idlist); } else if (f.length() > data_file_ext.length() && f.substr(f.length() - data_file_ext.length()) == data_file_ext) { std::string id = f.substr(0, f.length() - data_file_ext.length()); // log_info("found file " << dir << " for id " << id); data_files[id] = dir; idlist.push_back(id); } } }
static void debug_print_directories() { g_printf("data directory: %s\n", get_data_dir()); g_printf("doc directory: %s\n", get_doc_dir()); g_printf("ui directory: %s\n", get_ui_dir()); g_printf("glade directory: %s\n", get_glade_dir()); g_printf("icon directory: %s\n", get_icon_dir()); g_printf("plugin directory: %s\n", get_plugin_dir()); g_printf("script directory: %s\n", get_script_dir()); }
void launch_manual() { char command[512]; char *manual_file = find_manual_file(); if (!manual_file) { fprintf(stderr, "No manual found.\n"); return; } #ifdef __APPLE__ snprintf(command, sizeof(command), "%s/%s", get_data_dir(), manual_file); void open_file_with_browser_mac(char *file); open_file_with_browser_mac(command); #else switch (arch) { case ARCH_WETAB: snprintf(command, sizeof(command), "tiitoo-browser-bin -t file://%s/%s", get_data_dir(), manual_file); break; case ARCH_WIN32: case ARCH_WIN64: snprintf(command, sizeof(command), "%s", manual_file); break; default: if (!strcmp(options_browser, "browser")) { strcpy(options_browser, "./browser.sh"); } snprintf(command, sizeof(command), "%s file://%s/%s", options_browser, get_data_dir(), manual_file); break; } launch_command(command); #endif }
gboolean config_get_config_file(gboolean is_applet) { gchar dir[512],*path; int length; if(get_data_dir(dir,512,is_applet)) { length = strlen(dir)+8; path = (gchar *)malloc(length*sizeof(gchar)); if(is_applet) snprintf(path,length, "%s/config", dir); else snprintf(path,length, "%s/config", dir); mpd_info.config_file = g_string_new(path); } else return FALSE; return TRUE; }
int main( int argc, char** argv ) { // parse command-line options boost::program_options::options_description option_config("Allowed options"); option_config.add_options()("data-dir", boost::program_options::value<std::string>(), "configuration data directory") ("help", "display this help message") ("p2p-port", boost::program_options::value<uint16_t>()->default_value(5678), "set port to listen on") ("maximum-number-of-connections", boost::program_options::value<uint16_t>(), "set the maximum number of peers this node will accept at any one time") ("upnp", boost::program_options::value<bool>()->default_value(true), "Enable UPNP") ("connect-to", boost::program_options::value<std::vector<std::string> >(), "set remote host to connect to") ("server", "enable JSON-RPC server") ("daemon", "run in daemon mode with no CLI console") ("rpcuser", boost::program_options::value<std::string>(), "username for JSON-RPC") ("rpcpassword", boost::program_options::value<std::string>(), "password for JSON-RPC") ("rpcport", boost::program_options::value<uint16_t>()->default_value(5679), "port to listen for JSON-RPC connections") ("httpport", boost::program_options::value<uint16_t>()->default_value(5680), "port to listen for HTTP JSON-RPC connections") ("genesis-config", boost::program_options::value<std::string>()->default_value("genesis.dat"), "generate a genesis state with the given json file (only accepted when the blockchain is empty)") ("clear-peer-database", "erase all information in the peer database") ("resync-blockchain", "delete our copy of the blockchain at startup, and download a fresh copy of the entire blockchain from the network") ("version", "print the version information for bts_xt_client"); boost::program_options::positional_options_description positional_config; positional_config.add("data-dir", 1); boost::program_options::variables_map option_variables; try { boost::program_options::store(boost::program_options::command_line_parser(argc, argv). options(option_config).positional(positional_config).run(), option_variables); boost::program_options::notify(option_variables); } catch (boost::program_options::error&) { std::cerr << "Error parsing command-line options\n\n"; std::cerr << option_config << "\n"; return 1; } if (option_variables.count("help")) { std::cout << option_config << "\n"; return 0; } if (option_variables.count("version")) { std::cout << "bts_xt_client built on " << __DATE__ << " at " << __TIME__ << "\n"; std::cout << " bitshares_toolkit revision: " << bts::utilities::git_revision_sha << "\n"; std::cout << " committed " << fc::get_approximate_relative_time_string(fc::time_point_sec(bts::utilities::git_revision_unix_timestamp)) << "\n"; std::cout << " fc revision: " << fc::git_revision_sha << "\n"; std::cout << " committed " << fc::get_approximate_relative_time_string(fc::time_point_sec(bts::utilities::git_revision_unix_timestamp)) << "\n"; return 0; } try { print_banner(); fc::path datadir = get_data_dir(option_variables); ::configure_logging(datadir); auto cfg = load_config(datadir); auto chain = load_and_configure_chain_database(datadir, option_variables); auto wall = std::make_shared<bts::wallet::wallet>(chain); wall->set_data_directory( datadir ); bts::client::client_ptr client = std::make_shared<bts::client::client>( chain ); _global_client = client.get(); client->set_wallet( wall ); client->run_delegate(); bts::rpc::rpc_server_ptr rpc_server = std::make_shared<bts::rpc::rpc_server>(); rpc_server->set_client(client); if( option_variables.count("server") ) { // the user wants us to launch the RPC server. // First, override any config parameters they bts::rpc::rpc_server::config rpc_config(cfg.rpc); if (option_variables.count("rpcuser")) rpc_config.rpc_user = option_variables["rpcuser"].as<std::string>(); if (option_variables.count("rpcpassword")) rpc_config.rpc_password = option_variables["rpcpassword"].as<std::string>(); // for now, force binding to localhost only if (option_variables.count("rpcport")) rpc_config.rpc_endpoint = fc::ip::endpoint(fc::ip::address("127.0.0.1"), option_variables["rpcport"].as<uint16_t>()); else rpc_config.rpc_endpoint = fc::ip::endpoint(fc::ip::address("127.0.0.1"), uint16_t(9988)); if (option_variables.count("httpport")) rpc_config.httpd_endpoint = fc::ip::endpoint(fc::ip::address("127.0.0.1"), option_variables["httpport"].as<uint16_t>()); std::cout<<"Starting json rpc server on "<< std::string( rpc_config.rpc_endpoint ) <<"\n"; std::cout<<"Starting http json rpc server on "<< std::string( rpc_config.httpd_endpoint ) <<"\n"; bool rpc_success = rpc_server->configure(rpc_config); if (!rpc_success) { std::cerr << "Error starting rpc server\n\n"; } } else { std::cout << "Not starting rpc server, use --server to enable the rpc interface\n"; } client->configure( datadir ); if (option_variables.count("maximum-number-of-connections")) { fc::mutable_variant_object params; params["maximum_number_of_connections"] = option_variables["maximum-number-of-connections"].as<uint16_t>(); client->network_set_advanced_node_parameters(params); } if (option_variables.count("p2p-port")) { auto p2pport = option_variables["p2p-port"].as<uint16_t>(); std::cout << "Listening to P2P connections on port "<<p2pport<<"\n"; client->listen_on_port(p2pport); if( option_variables["upnp"].as<bool>() ) { std::cout << "Attempting to map UPNP port...\n"; auto upnp_service = new bts::net::upnp_service(); upnp_service->map_port( p2pport ); fc::usleep( fc::seconds(3) ); } } if (option_variables.count("clear-peer-database")) { std::cout << "Erasing old peer database\n"; client->get_node()->clear_peer_database(); } client->connect_to_p2p_network(); if (option_variables.count("connect-to")) { std::vector<std::string> hosts = option_variables["connect-to"].as<std::vector<std::string>>(); for( auto peer : hosts ) { client->connect_to_peer( peer ); } } else { client->connect_to_peer( "107.170.30.182:5678" ); } if( !option_variables.count("daemon") ) { auto cli = std::make_shared<bts::cli::cli>( client, rpc_server ); cli->wait(); } else if( option_variables.count( "server" ) ) // daemon & server { rpc_server->wait_on_quit(); } else // daemon !server { std::cerr << "You must start the rpc server in daemon mode\n"; } } catch ( const fc::exception& e ) { std::cerr << "------------ error --------------\n" << e.to_detail_string() << "\n"; wlog( "${e}", ("e", e.to_detail_string() ) ); } return 0; }
int main( int argc, char** argv ) { // parse command-line options boost::program_options::options_description option_config("Allowed options"); option_config.add_options()("data-dir", boost::program_options::value<std::string>(), "configuration data directory") ("help", "display this help message") ("p2p", "enable p2p mode") ("port", boost::program_options::value<uint16_t>(), "set port to listen on") ("connect-to", boost::program_options::value<std::string>(), "set remote host to connect to") ("server", "enable JSON-RPC server") ("rpcuser", boost::program_options::value<std::string>(), "username for JSON-RPC") ("rpcpassword", boost::program_options::value<std::string>(), "password for JSON-RPC") ("rpcport", boost::program_options::value<uint16_t>(), "port to listen for JSON-RPC connections") ("httpport", boost::program_options::value<uint16_t>(), "port to listen for HTTP JSON-RPC connections") ("trustee-private-key", boost::program_options::value<std::string>(), "act as a trustee using the given private key") ("trustee-address", boost::program_options::value<std::string>(), "trust the given BTS address to generate blocks") ("genesis-json", boost::program_options::value<std::string>(), "generate a genesis block with the given json file (only for testing, only accepted when the blockchain is empty)"); boost::program_options::positional_options_description positional_config; positional_config.add("data-dir", 1); boost::program_options::variables_map option_variables; try { boost::program_options::store(boost::program_options::command_line_parser(argc, argv). options(option_config).positional(positional_config).run(), option_variables); boost::program_options::notify(option_variables); } catch (boost::program_options::error&) { std::cerr << "Error parsing command-line options\n\n"; std::cerr << option_config << "\n"; return 1; } if (option_variables.count("help")) { std::cout << option_config << "\n"; return 0; } bool p2p_mode = option_variables.count("p2p") != 0; try { print_banner(); fc::path datadir = get_data_dir(option_variables); ::configure_logging(datadir); auto cfg = load_config(datadir); auto chain = load_and_configure_chain_database(datadir, option_variables); auto wall = std::make_shared<bts::wallet::wallet>(); wall->set_data_directory( datadir ); auto c = std::make_shared<bts::client::client>(p2p_mode); c->set_chain( chain ); c->set_wallet( wall ); if (option_variables.count("trustee-private-key")) { auto key = fc::variant(option_variables["trustee-private-key"].as<std::string>()).as<fc::ecc::private_key>(); c->run_trustee(key); } else if( fc::exists( "trustee.key" ) ) { auto key = fc::json::from_file( "trustee.key" ).as<fc::ecc::private_key>(); c->run_trustee(key); } bts::rpc::rpc_server_ptr rpc_server = std::make_shared<bts::rpc::rpc_server>(); rpc_server->set_client(c); if( option_variables.count("server") ) { // the user wants us to launch the RPC server. // First, override any config parameters they bts::rpc::rpc_server::config rpc_config(cfg.rpc); if (option_variables.count("rpcuser")) rpc_config.rpc_user = option_variables["rpcuser"].as<std::string>(); if (option_variables.count("rpcpassword")) rpc_config.rpc_password = option_variables["rpcpassword"].as<std::string>(); // for now, force binding to localhost only if (option_variables.count("rpcport")) rpc_config.rpc_endpoint = fc::ip::endpoint(fc::ip::address("127.0.0.1"), option_variables["rpcport"].as<uint16_t>()); if (option_variables.count("httpport")) rpc_config.httpd_endpoint = fc::ip::endpoint(fc::ip::address("127.0.0.1"), option_variables["httpport"].as<uint16_t>()); std::cerr<<"starting json rpc server on "<< std::string( rpc_config.rpc_endpoint ) <<"\n"; std::cerr<<"starting http json rpc server on "<< std::string( rpc_config.httpd_endpoint ) <<"\n"; rpc_server->configure(rpc_config); } if (p2p_mode) { c->configure( datadir ); if (option_variables.count("port")) c->listen_on_port(option_variables["port"].as<uint16_t>()); c->connect_to_p2p_network(); if (option_variables.count("connect-to")) c->connect_to_peer(option_variables["connect-to"].as<std::string>()); } else { if (option_variables.count("connect-to")) c->add_node(option_variables["connect-to"].as<std::string>()); else c->add_node( "127.0.0.1:4569" ); } auto cli = std::make_shared<bts::cli::cli>( c, rpc_server ); cli->wait(); } catch ( const fc::exception& e ) { wlog( "${e}", ("e", e.to_detail_string() ) ); } return 0; }
void gtkpod_init(int argc, char *argv[]) { AnjutaPluginManager *plugin_manager; AnjutaProfileManager *profile_manager; AnjutaApp *app; AnjutaStatus *status; AnjutaProfile *profile; GFile *session_profile; GError *error = NULL; gchar *default_profile_file = NULL; gchar *user_profile_file = NULL; gchar *ui_file = NULL; gchar *remembered_plugins = NULL; gchar *session_dir = NULL; gchar *splash = NULL; /* Initialise important directories */ init_directories(argv); register_stock_icon(GTKPOD_ICON, GTKPOD_ICON_STOCK_ID); /* Initialise the ui file */ ui_file = g_build_filename(get_ui_dir(), "gtkpod.ui", NULL); anjuta_set_ui_file_path(ui_file); /* Register the application icon */ register_stock_icon("gtkpod", GTKPOD_APP_ICON_STOCK_ID); /* Initialize application class instance*/ app = ANJUTA_APP(anjuta_app_new()); gtkpod_app = GTKPOD_APP(app); /* Initialise the preferences as required for the display of the splash screen */ prefs_init(argc, argv); /* Show some progress as the app is initialised */ status = anjuta_shell_get_status(ANJUTA_SHELL(app), NULL); anjuta_status_progress_add_ticks(status, 1); /* Show the splash screen if user requires */ if (! prefs_get_int(DISABLE_SPLASH_SCREEN)) { splash = g_build_filename(get_icon_dir(), "gtkpod-splash.png", NULL); if (g_file_test(splash, G_FILE_TEST_IS_REGULAR)) anjuta_status_set_splash(status, splash, 100); else { anjuta_status_disable_splash(status, TRUE); } g_free(splash); } /* * initialise gtkpod library items. Needs to be safety threaded due * to splash screen. */ gdk_threads_enter(); gp_init(argc, argv); gdk_threads_leave(); /* Add blocking widgets from the framework */ add_blocked_widget(app->toolbar); add_blocked_widget(app->view_menu); /* Set up shutdown signals */ g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK( on_gtkpod_delete_event), NULL); g_signal_connect(G_OBJECT(app), "destroy", G_CALLBACK(on_gtkpod_destroy), NULL); plugin_manager = anjuta_shell_get_plugin_manager(ANJUTA_SHELL(app), NULL); profile_manager = anjuta_shell_get_profile_manager(ANJUTA_SHELL(app), NULL); /* Restore remembered plugins */ remembered_plugins = g_settings_get_string(app->settings, GTKPOD_REMEMBERED_PLUGINS); if (remembered_plugins) anjuta_plugin_manager_set_remembered_plugins(plugin_manager, remembered_plugins); g_free(remembered_plugins); /* Load default profile */ default_profile_file = get_default_profile_path(); profile = anjuta_profile_new(USER_PROFILE_NAME, plugin_manager); session_profile = g_file_new_for_path(default_profile_file); anjuta_profile_add_plugins_from_xml(profile, session_profile, TRUE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_object_unref(session_profile); g_free(default_profile_file); /* Load user session profile */ user_profile_file = get_user_profile_path(); session_profile = g_file_new_for_path(user_profile_file); if (g_file_query_exists(session_profile, NULL)) { anjuta_profile_add_plugins_from_xml(profile, session_profile, FALSE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } } anjuta_profile_set_sync_file(profile, session_profile); g_object_unref(session_profile); g_free(user_profile_file); /* Load profile */ anjuta_profile_manager_freeze(profile_manager); anjuta_profile_manager_push(profile_manager, profile, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } /* Prepare for session save and load on profile change */ g_signal_connect (profile_manager, "profile-scoped", G_CALLBACK (on_profile_scoped), app); anjuta_profile_manager_thaw(profile_manager, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_signal_connect (profile_manager, "profile-descoped", G_CALLBACK (on_profile_descoped), app); gdk_threads_enter(); gp_init_itdbs(); gdk_threads_leave(); /* Load layout.*/ session_dir = get_user_session_dir(); if (!g_file_test(session_dir, G_FILE_TEST_IS_DIR)) session_dir = g_strdup(get_data_dir()); /* Restore session */ anjuta_shell_session_load(ANJUTA_SHELL(app), session_dir, NULL); g_free(session_dir); anjuta_status_progress_tick(status, NULL, _("Loaded Session...")); anjuta_status_disable_splash(status, TRUE); gtk_window_set_default_icon_name("gtkpod"); gtk_window_set_auto_startup_notification(TRUE); gtk_window_set_role(GTK_WINDOW(app), "gtkpod-app"); gtk_widget_show(GTK_WIDGET(app)); }
static gchar* get_default_profile_path() { return g_build_filename(get_data_dir(), "default.profile", NULL); }
std::string data_file_handler::get_path(const std::string& objectid) const { return get_data_dir() + get_rel_path(objectid); }
int main( int argc, char** argv ) { exit_signal = false; // parse command-line options boost::program_options::options_description option_config("Allowed options"); option_config.add_options()("data-dir", boost::program_options::value<std::string>(), "configuration data directory") ("help", "display this help message") ("p2p", "enable p2p mode") ("port", boost::program_options::value<uint16_t>(), "set port to listen on") ("connect-to", boost::program_options::value<std::string>(), "set remote host to connect to") ("trustee-private-key", boost::program_options::value<std::string>(), "act as a trustee using the given private key") ("trustee-address", boost::program_options::value<std::string>(), "trust the given BTS address to generate blocks") ("genesis-json", boost::program_options::value<std::string>(), "generate a genesis block with the given json file (only for testing, only accepted when the blockchain is empty)") ("rpconly", "run rpc server only, no gui"); boost::program_options::positional_options_description positional_config; positional_config.add("data-dir", 1); boost::program_options::variables_map option_variables; try { boost::program_options::store(boost::program_options::command_line_parser(argc, argv). options(option_config).positional(positional_config).run(), option_variables); boost::program_options::notify(option_variables); } catch (boost::program_options::error&) { std::cerr << "Error parsing command-line options\n\n"; std::cerr << option_config << "\n"; return 1; } if (option_variables.count("help")) { std::cout << option_config << "\n"; return 0; } fc::path datadir = get_data_dir(option_variables); BtsXtThread btsxt(option_variables, datadir); btsxt.start(); QString initial_url = "http://127.0.0.1:9989"; if(!fc::exists( datadir / "default_wallet.dat" )) initial_url = "http://127.0.0.1:9989/blank.html#/createwallet"; if(option_variables.count("rpconly")) { signal(SIGABRT, &handle_signal); signal(SIGTERM, &handle_signal); signal(SIGINT, &handle_signal); while(!exit_signal && btsxt.isRunning()) fc::usleep(fc::microseconds(10000)); } else { QApplication app(argc, argv); Html5Viewer viewer; viewer.setOrientation(Html5Viewer::ScreenOrientationAuto); viewer.resize(1024,648); viewer.show(); QUrl url = QUrl(initial_url); url.setUserName(""); url.setPassword(""); viewer.loadUrl(url); app.exec(); } btsxt.cancel(); btsxt.wait(); return 1; }