Advertisement
peter9477

Retrieve version from MANIFEST, for PlayBook AIR apps

Jun 6th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----------------------------------
  2. // Retrieve application version from metadata.
  3. //
  4. static public function getAppVersion():String {
  5.     // The alternative to this mess is to use File.userDirectory, but I don't consider
  6.     // that guaranteed to always point to the parent of app/META-INF
  7.     var manifest:File = new File(File.applicationDirectory.nativePath).resolvePath('../META-INF/MANIFEST.MF');
  8.  
  9.     var file:FileStream = new FileStream();
  10.     file.open(manifest, FileMode.READ);
  11.     var text:String = file.readUTFBytes(Math.min(manifest.size, 1000));
  12.     return /Application-Version: (.+)/i.exec(text)[1];
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement