Search code examples
iosdelphidelphi-xe4

XE4 getting the total disk size


can someone points or helps me in getting the IPHONE / IPAD device total disk size using the Delphi XE4 .

i need just a start point , i tried to use the :

Device : UIDevice;

but it has no reference .

thank you


Solution

  • uses
      iOSapi.Foundation, Macapi.ObjectiveC;
    
    function GetTotalDiskSize(FolderName: string): Int64;
    var
      Dict: NSDictionary;
      P: Pointer;
    const
      FoundationFwk: string = '/System/Library/Frameworks/Foundation.framework/Foundation';
    begin
      Result := 0;
      Dict := TNSFileManager.Wrap(TNSFileManager.OCClass.defaultManager).attributesOfFileSystemForPath(NSStr(FolderName), nil);
      if Dict = nil then
        Exit;
      P := Dict.objectForKey((CocoaNSStringConst(FoundationFwk, 'NSFileSystemSize') as ILocalObject).GetObjectID);
      if Assigned(P) then
        Result := TNSNumber.Wrap(P).unsignedLongLongValue;
    end;