UIDevice+VLC.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*****************************************************************************
  2. * UIDevice+VLC
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2017 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. * Carola Nitz <caro # videolan.org>
  10. *
  11. * Refer to the COPYING file of the official project for license.
  12. *****************************************************************************/
  13. #import "UIDevice+VLC.h"
  14. #import <sys/sysctl.h> // for sysctlbyname
  15. #import <sys/utsname.h>
  16. @implementation UIDevice (VLC)
  17. - (NSNumber *)VLCFreeDiskSpace
  18. {
  19. NSNumber *totalSpace;
  20. NSNumber *totalFreeSpace;
  21. NSError *error = nil;
  22. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  23. NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
  24. if (!error) {
  25. totalSpace = [dictionary objectForKey:NSFileSystemSize];
  26. totalFreeSpace = [dictionary objectForKey:NSFileSystemFreeSize];
  27. NSString *totalSize = [NSByteCountFormatter stringFromByteCount:[totalSpace longLongValue] countStyle:NSByteCountFormatterCountStyleFile];
  28. NSString *totalFreeSize = [NSByteCountFormatter stringFromByteCount:[totalFreeSpace longLongValue] countStyle:NSByteCountFormatterCountStyleFile];
  29. APLog(@"Memory Capacity of %@ with %@ Free memory available.", totalSize, totalFreeSize);
  30. } else
  31. APLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);
  32. return totalFreeSpace;
  33. }
  34. - (BOOL)VLCHasExternalDisplay
  35. {
  36. return ([[UIScreen screens] count] > 1);
  37. }
  38. @end