mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
DiskIO (macOS): detect disk size
This commit is contained in:
@@ -63,6 +63,12 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
ffStrbufPrependS(&device->devPath, "/dev/");
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFNumberRef mediaSize = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOMediaSizeKey), kCFAllocatorDefault, kNilOptions);
|
||||
if (mediaSize)
|
||||
ffCfNumGetInt64(mediaSize, (int64_t*) &device->size);
|
||||
else
|
||||
device->size = 0;
|
||||
|
||||
ffStrbufInit(&device->interconnect);
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryPhysical = 0;
|
||||
if (IORegistryEntryGetParentEntry(entryDriver, kIOServicePlane, &entryPhysical) == KERN_SUCCESS)
|
||||
|
||||
+20
-15
@@ -1,5 +1,24 @@
|
||||
#include "cf_helpers.h"
|
||||
|
||||
const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result)
|
||||
{
|
||||
if(CFGetTypeID(cf) == CFNumberGetTypeID())
|
||||
{
|
||||
if(!CFNumberGetValue((CFNumberRef)cf, kCFNumberSInt64Type, result))
|
||||
return "Number type is not SInt64";
|
||||
return NULL;
|
||||
}
|
||||
else if(CFGetTypeID(cf) == CFDataGetTypeID())
|
||||
{
|
||||
if(CFDataGetLength((CFDataRef)cf) != sizeof(int64_t))
|
||||
return "Data length is not sizeof(int64_t)";
|
||||
CFDataGetBytes((CFDataRef)cf, CFRangeMake(0, sizeof(int64_t)), (uint8_t*)result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return "TypeID is neither 'CFNumber' nor 'CFData'";
|
||||
}
|
||||
|
||||
const char* ffCfStrGetString(CFStringRef str, FFstrbuf* result)
|
||||
{
|
||||
if (!str)
|
||||
@@ -89,21 +108,7 @@ const char* ffCfDictGetInt64(CFDictionaryRef dict, CFStringRef key, int64_t* res
|
||||
if(cf == NULL)
|
||||
return "CFDictionaryGetValue() failed";
|
||||
|
||||
if(CFGetTypeID(cf) == CFNumberGetTypeID())
|
||||
{
|
||||
if(!CFNumberGetValue((CFNumberRef)cf, kCFNumberSInt64Type, result))
|
||||
return "Number type is not SInt64";
|
||||
return NULL;
|
||||
}
|
||||
else if(CFGetTypeID(cf) == CFDataGetTypeID())
|
||||
{
|
||||
if(CFDataGetLength((CFDataRef)cf) != sizeof(int64_t))
|
||||
return "Data length is not sizeof(int64_t)";
|
||||
CFDataGetBytes((CFDataRef)cf, CFRangeMake(0, sizeof(int64_t)), (uint8_t*)result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return "TypeID is neither 'CFNumber' nor 'CFData'";
|
||||
return ffCfNumGetInt64(cf, result);
|
||||
}
|
||||
|
||||
const char* ffCfDictGetData(CFDictionaryRef dict, CFStringRef key, uint32_t offset, uint32_t size, uint8_t* result, uint32_t* length)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
//Return error info if failed, NULL otherwise
|
||||
const char* ffCfStrGetString(CFStringRef str, FFstrbuf* result);
|
||||
const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result);
|
||||
const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* result);
|
||||
const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result);
|
||||
const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result);
|
||||
|
||||
Reference in New Issue
Block a user