MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / _rpcsx_initialize

Function _rpcsx_initialize

android/src/rpcsx-android.cpp:1714–1822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1712}
1713
1714extern "C" bool _rpcsx_initialize(std::string_view rootDir,
1715 std::string_view user) {
1716 auto rootDirStr = fix_dir_path(std::string(rootDir));
1717
1718 if (g_android_executable_dir != rootDirStr) {
1719 g_android_executable_dir = rootDirStr;
1720 g_android_config_dir = rootDirStr + "config/";
1721 g_android_cache_dir = rootDirStr + "cache/";
1722
1723 std::filesystem::create_directories(g_android_config_dir);
1724 std::error_code ec;
1725 // std::filesystem::remove_all(g_android_cache_dir, ec);
1726 std::filesystem::create_directories(g_android_cache_dir);
1727 }
1728
1729 if (g_initialized) {
1730 return true;
1731 }
1732
1733 g_initialized = true;
1734
1735 if (int r = libusb_set_option(nullptr, LIBUSB_OPTION_NO_DEVICE_DISCOVERY,
1736 nullptr);
1737 r != 0) {
1738 rpcsx_android.warning(
1739 "libusb_set_option(LIBUSB_OPTION_NO_DEVICE_DISCOVERY) -> %d", r);
1740 }
1741
1742 // Initialize thread pool finalizer // ???
1743 static_cast<void>(named_thread("", [](int) {}));
1744
1745 static std::unique_ptr<logs::listener> log_file;
1746 {
1747 // Check free space
1748 fs::device_stat stats{};
1749 if (!fs::statfs(fs::get_cache_dir(), stats) ||
1750 stats.avail_free < 128 * 1024 * 1024) {
1751 std::fprintf(stderr, "Not enough free space for logs (%f KB)",
1752 stats.avail_free / 1000000.);
1753 }
1754
1755 // preserve old log file
1756 if (std::filesystem::exists(fs::get_log_dir() + "RPCSX.log")) {
1757 std::error_code ec;
1758 std::filesystem::remove(fs::get_log_dir() + "RPCSX.old.log", ec);
1759 std::filesystem::rename(fs::get_log_dir() + "RPCSX.log",
1760 fs::get_log_dir() + "RPCSX.old.log", ec);
1761 }
1762
1763 // Limit log size to ~25% of free space
1764 log_file = logs::make_file_listener(fs::get_log_dir() + "RPCSX.log",
1765 stats.avail_free / 4);
1766 }
1767
1768 logs::stored_message ver{rpcsx_android.always()};
1769 ver.text = fmt::format("RPCSX-ps3-android v%s", rx::getVersion().toString());
1770
1771 // Write System information

Callers

nothing calls this directly

Calls 15

fix_dir_pathFunction · 0.85
get_cache_dirFunction · 0.85
renameFunction · 0.85
set_initFunction · 0.85
setupCallbacksFunction · 0.85
toStringMethod · 0.80
errorMethod · 0.80
SetHasGuiMethod · 0.80
SetUsrMethod · 0.80
stringFunction · 0.50
named_threadClass · 0.50
statfsClass · 0.50

Tested by

no test coverage detected