| 1 |
''' |
| 2 |
iOS Storage Path |
| 3 |
-------------------- |
| 4 |
''' |
| 5 |
|
| 6 |
from plyer.facades import StoragePath |
| 7 |
from pyobjus import autoclass |
| 8 |
import os |
| 9 |
|
| 10 |
NSFileManager = autoclass('NSFileManager') |
| 11 |
|
| 12 |
|
| 13 |
NSApplicationDirectory = 1 |
| 14 |
NSDocumentDirectory = 9 |
| 15 |
NSDownloadsDirectory = 15 |
| 16 |
NSMoviesDirectory = 17 |
| 17 |
NSMusicDirectory = 18 |
| 18 |
NSPicturesDirectory = 19 |
| 19 |
|
| 20 |
|
| 21 |
class iOSStoragePath(StoragePath): |
| 22 |
|
| 23 |
def __init__(self): |
| 24 |
self.defaultManager = NSFileManager.defaultManager() |
| 25 |
|
| 26 |
def _get_home_dir(self): |
| 27 |
return os.path.expanduser('~/') |
| 28 |
|
| 29 |
def _get_external_storage_dir(self): |
| 30 |
return 'This feature is not implemented for this platform.' |
| 31 |
|
| 32 |
def _get_root_dir(self): |
| 33 |
return 'This feature is not implemented for this platform.' |
| 34 |
|
| 35 |
def _get_documents_dir(self): |
| 36 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 37 |
NSDocumentDirectory, 1).firstObject().absoluteString.UTF8String() |
| 38 |
|
| 39 |
def _get_downloads_dir(self): |
| 40 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 41 |
NSDownloadsDirectory, 1).firstObject().absoluteString.UTF8String() |
| 42 |
|
| 43 |
def _get_videos_dir(self): |
| 44 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 45 |
NSMoviesDirectory, 1).firstObject().absoluteString.UTF8String() |
| 46 |
|
| 47 |
def _get_music_dir(self): |
| 48 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 49 |
NSMusicDirectory, 1).firstObject().absoluteString.UTF8String() |
| 50 |
|
| 51 |
def _get_pictures_dir(self): |
| 52 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 53 |
NSPicturesDirectory, 1).firstObject().absoluteString.UTF8String() |
| 54 |
|
| 55 |
def _get_application_dir(self): |
| 56 |
return self.defaultManager.URLsForDirectory_inDomains_( |
| 57 |
NSApplicationDirectory, 1).firstObject().absoluteString.\ |
| 58 |
UTF8String() |
| 59 |
|
| 60 |
|
| 61 |
def instance(): |
| 62 |
return iOSStoragePath() |