getSizeString64

This commit is contained in:
lunarcleint
2025-03-26 14:37:24 -07:00
parent 664954e30f
commit 4ab77a4eb6
2 changed files with 30 additions and 3 deletions
@@ -100,7 +100,7 @@ class SystemInfo extends FramerateCategory {
Logs.trace('Unable to grab GPU VRAM', ERROR, RED);
else {
var vRAMBytesFloat:#if cpp Float64 #else Float #end = vRAMBytes*1024;
vRAM = CoolUtil.getSizeString(vRAMBytesFloat);
vRAM = CoolUtil.getSizeString64(vRAMBytesFloat);
}
}
} else
+29 -2
View File
@@ -301,7 +301,7 @@ final class CoolUtil
* @param size Size to convert to string
* @return String Result string representation
*/
public static function getSizeString(size: #if cpp Float64 #else Float #end):String {
public static function getSizeString(size:Float):String {
var rSize:Float = size;
var label:Int = 0;
var len = sizeLabels.length;
@@ -312,6 +312,23 @@ final class CoolUtil
return Std.int(rSize) + ((label <= 1) ? "" : "." + addZeros(Std.string(Std.int((rSize % 1) * 100)), 2)) + sizeLabels[label];
}
/**
* Returns a string representation of a size, following this format: `1.02 GB`, `134.00 MB`, using Float64 on cpp targets
* @param size Size to convert to string
* @return String Result string representation
*/
public static function getSizeString64(size: #if cpp Float64 #else Float #end):String {
var rSize: #if cpp Float64 #else Float #end = size;
var label:Int = 0;
var len = sizeLabels.length;
while(rSize >= 1024 && label < len-1) {
label++;
rSize /= 1024;
}
return Std.int(rSize) + ((label <= 1) ? "" : "." + addZeros(Std.string(Std.int((rSize % 1) * 100)), 2)) + sizeLabels[label];
}
/**
* Replaces in a string any kind of IP with `[Your IP]` making the string safer to trace.
* @param msg String to check and edit
@@ -809,7 +826,17 @@ final class CoolUtil
* @param path
*/
public static inline function browsePath(path:String) {
var formattedPath:String = Path.normalize(path);
#if windows
formattedPath = formattedPath.replace("/", "\\");
Sys.command("explorer", [formattedPath]);
#elseif mac
Sys.command("open", [formattedPath]);
#elseif linux
var cmd = Sys.command("xdg-open", [formattedPath]);
if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [formattedPath]);
#end
}
/**