public long CopyTo(string relativeTargetPath, HashSet <ApplicationFileInfo> localGameSet) { string targetDir = relativeTargetPath.Trim('/') + "/" + desktop.Code; var desktopStream = getAdjustedDesktopFile().SaveTo(new MemoryStream(), false, true); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.desktop", DateTime.UtcNow, desktopStream)); var maxX = 228; var maxY = 204; var sourcePath = getImagePath(ImageId); Stream iconStream, smallIconStream; var mdMiniStream = new MemoryStream(); if (sourcePath != null) { var smallSourcePath = sourcePath.Replace(".png", "_small.png"); if (!File.Exists(smallSourcePath)) { smallSourcePath = sourcePath; } iconStream = ProcessImageFileToStream(sourcePath, maxX, maxY, true, false, false); smallIconStream = ProcessImageFileToStream(smallSourcePath, 40, 40, true, false, false); SetMdMini(sourcePath, MdMiniImageType.Front, mdMiniStream); var spinePath = getSpinePath(imageId); if (spinePath != null) { SetMdMini(spinePath, MdMiniImageType.Spine, mdMiniStream); } localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.png", File.GetLastWriteTimeUtc(sourcePath), iconStream)); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}_small.png", File.GetLastWriteTimeUtc(smallSourcePath), smallIconStream)); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}_mdmini.png", DateTime.UtcNow, mdMiniStream)); } else { iconStream = ProcessImageToStream(Image, maxX, maxY, true, false, false); smallIconStream = ProcessImageToStream(Image, 40, 40, true, false, false); SetMdMini(Image as Bitmap, MdMiniImageType.Front, mdMiniStream); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.png", DateTime.UtcNow, iconStream)); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}_small.png", DateTime.UtcNow, smallIconStream)); localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}_mdmini.png", DateTime.UtcNow, mdMiniStream)); } long calculatedSize = Shared.PadFileSize(desktopStream.Length, hakchi.BLOCK_SIZE) + Shared.PadFileSize(iconStream.Length, hakchi.BLOCK_SIZE) + Shared.PadFileSize(smallIconStream.Length, hakchi.BLOCK_SIZE); Shared.PadFileSize(mdMiniStream.Length, hakchi.BLOCK_SIZE); return(calculatedSize); }
/// <summary> /// Returns cumulative size of files in the set /// </summary> public static long GetSize(this HashSet <ApplicationFileInfo> set, long padFileSize = -1) { long size = 0; foreach (var afi in set) { size += Shared.PadFileSize(afi.FileSize, padFileSize); } return(size); }