/// <summary> /// Gathers all the assets from a specific folder into our asset folder /// </summary> public void GatherAssetFiles(string fromDir) { if (!IO.Directory.Exists(AssetDirectory)) { IO.Directory.CreateDirectory(AssetDirectory); } string blob = AssetHandler.getStartingDirectory(fromDir, "BLOBS"); string asset = AssetHandler.getStartingDirectory(fromDir, "assets"); foreach (string file in directoryServer.AssetManifestList) { //Check the inner zone asset folder first string filePath = AssetHandler.findAssetFile(file, asset); if (filePath == null) { //Get it from the blob folder instead filePath = AssetHandler.findAssetFile(file, blob); if (filePath == null) { //Still cant find it? Just skip it continue; } } if (filePath != null) { try { string path = IO.Path.Combine(AssetDirectory, file); //Lets copy it over if (IO.File.Exists(path)) { IO.File.Delete(path); } IO.File.Copy(filePath, path); } catch (Exception e) { Log.write(TLog.Warning, e.ToString()); } } } }
/// <summary> /// Gets a requested file for a client and returns in bytes /// </summary> public byte[] GetFile(string assetName) { if (string.IsNullOrEmpty(assetName)) { return(null); } string asset = AssetHandler.findAssetFile(assetName, AssetDirectory); if (asset != null) { IO.FileStream fileStream = IO.File.OpenRead(asset); byte[] bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, bytes.Length); fileStream.Close(); return(bytes); } return(null); }