95 lines
2.5 KiB
ActionScript
95 lines
2.5 KiB
ActionScript
package net.pixvi.myrloader.center
|
|
{
|
|
import flash.filesystem.File;
|
|
import flash.utils.ByteArray;
|
|
import net.pixvi.pfw.utils.core.Singleton;
|
|
import net.pixvi.pse.file.FileTools;
|
|
|
|
public class MyrUpdateCenter extends Singleton
|
|
{
|
|
|
|
public static var updateLocalSrcPrefix:String = "app-storage:/";
|
|
|
|
public static var updateServer:String = "http://resource.myrzx.cn/updateserver1/verFfcs/";
|
|
|
|
public var updateFiles:Object = {};
|
|
|
|
public var version:Number = 0;
|
|
|
|
public var buildVersion:Number = 0;
|
|
|
|
public var versionList:Array;
|
|
|
|
public var lastVersion:Number;
|
|
|
|
public var versionListFile:Object;
|
|
|
|
public function MyrUpdateCenter()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function getUpdateSrc(src:String) : String
|
|
{
|
|
if(src.charAt(0) == "/")
|
|
{
|
|
src = src.substr(1);
|
|
}
|
|
if(checkSrc(src))
|
|
{
|
|
return updateLocalSrcPrefix + src;
|
|
}
|
|
return src;
|
|
}
|
|
|
|
public static function getStorageSrcIfExist(src:String) : String
|
|
{
|
|
if(File.applicationStorageDirectory.resolvePath(src).exists)
|
|
{
|
|
return File.applicationStorageDirectory.resolvePath(src).url;
|
|
}
|
|
return src;
|
|
}
|
|
|
|
public static function checkSrc(src:String) : Boolean
|
|
{
|
|
return getIns().updateFiles[src] != null;
|
|
}
|
|
|
|
public static function getStorageFileIfExist(src:String) : File
|
|
{
|
|
var file:File = File.applicationStorageDirectory.resolvePath(src);
|
|
if(file.exists)
|
|
{
|
|
return file;
|
|
}
|
|
return File.applicationDirectory.resolvePath(src);
|
|
}
|
|
|
|
public static function swfSrcToBytes(src:String) : ByteArray
|
|
{
|
|
var file:File = new File(src);
|
|
return FileTools.readFileBytes(file);
|
|
}
|
|
|
|
public static function getIns() : MyrUpdateCenter
|
|
{
|
|
return Singleton.getInstanceOrCreate(MyrUpdateCenter) as MyrUpdateCenter;
|
|
}
|
|
|
|
public function getConfigSrcHackLib() : Object
|
|
{
|
|
var lib:Object = {};
|
|
for(var key:String in updateFiles)
|
|
{
|
|
if(updateFiles[key].type != null && updateFiles[key].type == "config")
|
|
{
|
|
lib[key] = updateLocalSrcPrefix + updateFiles[key].src;
|
|
}
|
|
}
|
|
return lib;
|
|
}
|
|
}
|
|
}
|
|
|