public static string GetFilePath(AssetRecord record, FileAddressType addressType) { if (record == null || addressType == FileAddressType.NULL) { return(null); } else { string address = ""; switch (addressType) { case FileAddressType.LOCAL: address = StrConst.Instance.LocalFileAddress; break; case FileAddressType.SERVER: address = StrConst.Instance.ServerFileAddress; break; case FileAddressType.DOWNLOAD_TEMP: address = StrConst.Instance.DownloadTempAddress; break; } string folder = GetFileFolderPath(record.Type); //断电续传下载到一半终止 服务器端已经发生变化之后再更新时 用于区别旧的临时文件 string fileName = addressType == FileAddressType.DOWNLOAD_TEMP ? record.ReleaseFileName + record.Version.ToString() : record.ReleaseFileName; return(new StringBuilder().AppendFormat("{0}{1}{2}", address, folder, fileName).ToString()); } }
// -------------------------------------------------------------------------------------------------------- public LoadFile(AssetRecord correlateRecord, LoadBehaviour behaviour, bool isCacheToRecord = false, Action <object> onloadingEnd = null, Action <LoadFile> onFileLoaded = null) { CorrelateRecord = correlateRecord; _Behaviour = behaviour; _IsCacheToRecord = isCacheToRecord; this.onloadingEnd = onloadingEnd; this.onFileLoaded = onFileLoaded; switch (behaviour) { case LoadBehaviour.ContentLoadFromLoacal_LoadBundleFile: case LoadBehaviour.ContentLoadFromLoacal_WWW: _LoadPathType = FileAddressType.LOCAL; break; case LoadBehaviour.ContentLoadFromServer_WWW: _LoadPathType = FileAddressType.SERVER; break; case LoadBehaviour.DownloadFile_ResumeBrokenTransfer_HttpWebRequest: case LoadBehaviour.DownloadFile_WWW: _LoadPathType = FileAddressType.SERVER; break; } }
private static string SetSaveFilePath(LoadFile loadFile) { if (loadFile == null) { return(null); } FileAddressType savePathType = loadFile.CorrelateRecord is AssetRecordsInfo ? FileAddressType.LOCAL : FileAddressType.DOWNLOAD_TEMP; string saveFilePath = null; if (savePathType == FileAddressType.LOCAL || savePathType == FileAddressType.DOWNLOAD_TEMP) { saveFilePath = GetFilePath(loadFile.CorrelateRecord, savePathType); DirectoryInfo folderPathInfo = new DirectoryInfo(Path.GetDirectoryName(saveFilePath)); if (!folderPathInfo.Exists) { folderPathInfo.Create(); } } return(saveFilePath); }