This commit is contained in:
watrabi
2025-09-18 17:55:52 -04:00
commit 977f1ff4b8
15030 changed files with 17324420 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
// !!!WARNING!!!
// Do NOT call back into FASTLOG here, since FASTLOG heavily depends on this,
// and we could end up getting a SIGABRT from a lock being set multiple times.
#include "util/FileSystem.h"
#include <iostream>
#include <boost/filesystem.hpp>
#include "RbxFormat.h"
#include "FastLog.h"
#include "rbx/Debug.h"
namespace RBX
{
namespace JNI
{
std::string fileSystemFilesDir; // Set in JNIRobloxSettings.cpp.
} // namespace JNI
} // namespace RBX
using namespace RBX;
using namespace RBX::JNI;
namespace RBX
{
namespace FileSystem
{
boost::filesystem::path getUserDirectory(bool create, FileSystemDir dir, const char *subDirectory)
{
boost::filesystem::path path;
if (subDirectory)
{
path /= subDirectory;
}
switch (dir)
{
case DirAppData:
path /= "appData";
break;
case DirExe:
path /= "exe";
break;
case DirPicture:
path /= "picture";
break;
case DirVideo:
path /= "video";
break;
}
return getCacheDirectory(true, path.native().c_str());
}
}}
+34
View File
@@ -0,0 +1,34 @@
#include "Util/MachineIdUploader.h"
#include <jni.h>
using namespace RBX;
bool MachineIdUploader::fillMachineId(MachineId *out) {
// Fetch the device unique id via JNI.
// out->macAddresses.push_back("device_id");
// return true;
// some incomplete, possible incorrect example code from the web
// JNIEnv &env = ...
// jobject activity = ... (android.app.Activity object)
// //TelephonyManager telephony_manager =
// getSystemService(Context.TELEPHONY_SERVICE);
// jmethodID mid = env.GetMethodID(env.GetObjectClass(activity),
// "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
// jobject telephony_manager = env.CallObjectMethod(activity, mid,
// env.NewStringUTF("phone"));
// //String s_imei = tm.getDeviceId();
// mid = env.GetMethodID(env.GetObjectClass(telephony_manager),
// "getDeviceId", "()Ljava/lang/String;");
// jstring s_imei = (jstring)env.CallObjectMethod(telephony_manager,
// mid);
// if(env.ExceptionCheck()){
// env.ExceptionClear();
// return false;
// }
// const jchar *imei = env.GetStringCritical(s_imei, NULL);
// // copy imei string anywhere you need
// env.ReleaseStringCritical(s_imei, imei);
return false;
}
+108
View File
@@ -0,0 +1,108 @@
#include "util/MemoryStats.h"
#include <fstream>
#include <sstream>
#include <string>
#include <regex>
namespace RBX
{
using RBX::MemoryStats::memsize_t;
class MemInfo
{
// Next 3 fields summed define how much memory is actually free.
memsize_t cacheKB;
memsize_t bufferKB;
memsize_t memfreeKB;
memsize_t totalKB;
bool readLine(const std::string& line, const std::string& target, memsize_t* field)
{
if (0 == line.find(target))
{
std::string expr = target + "\\s*(\\d+).*";
std::regex e(expr);
std::smatch sm;
if (std::regex_search(line, sm, e)) {
if (sm.size() >= 1) {
std::string o = sm[1].str(); // gets the first capture group
std::sscanf(o.c_str(), "%llu", field);
}
}
return true;
}
return false;
}
public:
MemInfo() : cacheKB(1), bufferKB(1), memfreeKB(1), totalKB(3)
{
std::ifstream fin("/proc/meminfo");
unsigned fieldsLoaded = 0;
while (fin && !fin.eof() && fieldsLoaded < 4)
{
std::string line;
std::getline(fin, line);
if (readLine(line, "MemTotal:", &totalKB))
{
++fieldsLoaded;
}
if (readLine(line, "MemFree:", &memfreeKB))
{
++fieldsLoaded;
}
if (readLine(line, "Buffers:", &bufferKB))
{
++fieldsLoaded;
}
if (readLine(line, "Cached:", &cacheKB))
{
++fieldsLoaded;
}
}
}
memsize_t freeBytes() const
{
return (memfreeKB + bufferKB + cacheKB) * 1024;
}
memsize_t totalBytes() const
{
return totalKB * 1024;
}
};
} // namespace rbx
namespace RBX {
namespace MemoryStats {
memsize_t usedMemoryBytes()
{
MemInfo mi;
return mi.totalBytes() - mi.freeBytes();
}
memsize_t freeMemoryBytes()
{
MemInfo mi;
return mi.freeBytes();
}
memsize_t totalMemoryBytes()
{
MemInfo mi;
return mi.totalBytes();
}
} // namespace MemoryStats
} // namespace RBX
+14
View File
@@ -0,0 +1,14 @@
#include "StringConv.h"
namespace RBX {
std::string utf8_encode(const std::string &path)
{
return path;
}
std::string utf8_decode(const std::string &path)
{
return path;
}
}