Unpack() public static method

Unpack the specified File, returns unpacked dir.
public static Unpack ( string sourceFileName, string savePath, bool decodeAudio = false, bool overwriteSongXml = false, Platform predefinedPlatform = null ) : string
sourceFileName string Source file path.
savePath string Save path.
decodeAudio bool If set to true decode audio.
overwriteSongXml bool If set to true overwrite existing song (EOF) xml with SNG data
predefinedPlatform Platform Predefined source platform.
return string
        /// <summary>
        /// Converts CDLC packages between platforms
        /// </summary>
        /// <param name="sourcePackage"></param>
        /// <param name="sourcePlatform"></param>
        /// <param name="targetPlatform"></param>
        /// <param name="appId"></param>
        /// <returns>Errors if any</returns>
        public static string Convert(string sourcePackage, Platform sourcePlatform, Platform targetPlatform, string appId)
        {
            var needRebuildPackage = sourcePlatform.IsConsole != targetPlatform.IsConsole;
            var tmpDir             = Path.GetTempPath();

            var unpackedDir = Packer.Unpack(sourcePackage, tmpDir, false, true, false, sourcePlatform);

            // DESTINATION
            var nameTemplate = (!targetPlatform.IsConsole) ? "{0}{1}.psarc" : "{0}{1}";
            var packageName  = Path.GetFileNameWithoutExtension(sourcePackage).StripPlatformEndName();

            packageName = packageName.Replace(".", "_");
            var targetFileName = String.Format(nameTemplate, Path.Combine(Path.GetDirectoryName(sourcePackage), packageName), targetPlatform.GetPathName()[2]);

            // CONVERSION
            if (needRebuildPackage)
            {
                ConvertPackageRebuilding(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
            }
            else
            {
                ConvertPackageForSimilarPlatform(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
            }

            DirectoryExtension.SafeDelete(unpackedDir);

            return(String.Empty);
        }
Example #2
0
        public static string Convert(string sourcePackage, Platform sourcePlatform, Platform targetPlatform, string appId)
        {
            var needRebuildPackage = sourcePlatform.IsConsole != targetPlatform.IsConsole;
            var tmpDir             = Path.GetTempPath();

            var fileName = Path.GetFileNameWithoutExtension(sourcePackage);

            if (sourcePlatform.platform == GamePlatform.PS3)
            {
                if (fileName.Contains(".psarc"))
                {
                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                }
            }

            var unpackedDir = Packer.Unpack(sourcePackage, tmpDir, false, true, false, sourcePlatform);

            // DESTINATION
            var nameTemplate = (!targetPlatform.IsConsole) ? "{0}{1}.psarc" : "{0}{1}";

            var packageName = Path.GetFileNameWithoutExtension(sourcePackage);

            if (packageName.EndsWith(new Platform(GamePlatform.Pc, GameVersion.None).GetPathName()[2]) ||
                packageName.EndsWith(new Platform(GamePlatform.Mac, GameVersion.None).GetPathName()[2]) ||
                packageName.EndsWith(new Platform(GamePlatform.XBox360, GameVersion.None).GetPathName()[2]) ||
                packageName.EndsWith(new Platform(GamePlatform.PS3, GameVersion.None).GetPathName()[2] + ".psarc"))
            {
                packageName = packageName.Substring(0, packageName.LastIndexOf("_"));
            }
            var targetFileName = Path.Combine(Path.GetDirectoryName(sourcePackage), String.Format(nameTemplate, Path.Combine(Path.GetDirectoryName(sourcePackage), packageName), targetPlatform.GetPathName()[2]));

            // CONVERSION
            if (needRebuildPackage)
            {
                ConvertPackageRebuilding(unpackedDir, targetFileName, targetPlatform, appId);
            }
            else
            {
                ConvertPackageForSimilarPlatform(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
            }

            DirectoryExtension.SafeDelete(unpackedDir);

            return(String.Empty);
        }