Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package;
  2.  
  3.  
  4. import flash.Lib;
  5. import openfl.utils.JNI;
  6.  
  7.  
  8. class SystemPath {
  9.  
  10.  
  11. public static var applicationDirectory (get, null):String;
  12. public static var applicationStorageDirectory (get, null):String;
  13. public static var desktopDirectory (get, null):String;
  14. public static var documentsDirectory (get, null):String;
  15. public static var userDirectory (get, null):String;
  16.  
  17. private static inline var APP = 0;
  18. private static inline var STORAGE = 1;
  19. private static inline var DESKTOP = 2;
  20. private static inline var DOCS = 3;
  21. private static inline var USER = 4;
  22.  
  23.  
  24.  
  25.  
  26. // Getters & Setters
  27.  
  28.  
  29.  
  30.  
  31. private static function get_applicationDirectory ():String { return nme_filesystem_get_special_dir (APP); }
  32. private static function get_applicationStorageDirectory ():String { return nme_filesystem_get_special_dir (STORAGE); }
  33. private static function get_desktopDirectory ():String { return nme_filesystem_get_special_dir (DESKTOP); }
  34. private static function get_documentsDirectory ():String { return nme_filesystem_get_special_dir (DOCS); }
  35. private static function get_userDirectory ():String { return nme_filesystem_get_special_dir (USER); }
  36.  
  37.  
  38.  
  39.  
  40. // Native Methods
  41.  
  42.  
  43.  
  44.  
  45. #if !android
  46.  
  47. private static var nme_filesystem_get_special_dir = Lib.load ("nme", "nme_filesystem_get_special_dir", 1);
  48.  
  49. #else
  50.  
  51. private static var jni_filesystem_get_special_dir:Dynamic = null;
  52.  
  53. private static function nme_filesystem_get_special_dir (inWhich:Int):String {
  54.  
  55. if (jni_filesystem_get_special_dir == null) {
  56.  
  57. jni_filesystem_get_special_dir = JNI.createStaticMethod ("org.haxe.nme.GameActivity", "getSpecialDir", "(I)Ljava/lang/String;");
  58.  
  59. }
  60.  
  61. return jni_filesystem_get_special_dir (inWhich);
  62.  
  63. }
  64.  
  65. #end
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement