Пример #1
0
        public void ReplaceSongPath(string songPath, string nameToReplace, string apkPath)
        {
            MainDatabase = Engine.Manager.MassFirstAsset <LevelDatabase>((oi) => true, false);
            if (MainDatabase == null || MainDatabase.Object == null)
            {
                throw new AssetsException("Could not find main level database!");
            }
            AlbumDatabase = Engine.Manager.MassFirstAsset <AlbumArtDatabase>((oi) => true, false);
            if (AlbumDatabase == null || AlbumDatabase.Object == null)
            {
                throw new AssetsException("Could not find album database!");
            }
            IObjectInfo <Koreography> targetKor = Engine.Manager.MassFirstAsset <Koreography>((o) => o.Object.Name == nameToReplace, false);

            if (targetKor == null || targetKor.Object == null)
            {
                throw new AssetsException("Could not find a Koreography object matching name: " + nameToReplace + "!");
            }
            var fp = new FolderFileProvider(songPath.GetDirectoryFwdSlash(), false);

            //var ac = LoadAudioClipObject(nameToReplace, songPath, fp);
            //MainDatabase.ParentFile.AddObject(ac);
            // Copy Existing Song Info and add it
            CopyExistingSongDataByIndex(indexToCopy);
            // Replace Song of copied data with desired song

            // Apply BNK modifications

            // Copy new song into folder
            //targetKor.Object.SourceClip = ac.PtrFrom(targetKor.Object);
            //targetKor.Object.SourceClipPath = "";
            File.Copy(songPath, apkPath.GetFilenameFwdSlash() + "/" + nameToReplace + ".wem", true);
            fp.Save(); // Save, simply to close
        }
Пример #2
0
        internal void PerformFileOperation(QaeConfig config)
        {
            try
            {
                IFileProvider provider;
                switch (ProviderType)
                {
                case QueuedFileOperationProviderType.Root:
                    provider = config.RootFileProvider;
                    break;

                case QueuedFileOperationProviderType.ModLibs:
                    provider = config.ModLibsFileProvider;
                    break;

                case QueuedFileOperationProviderType.FileSystemRoot:
                    provider = new FolderFileProvider("/", false);
                    break;

                default:
                    throw new NotImplementedException($"Provider type {ProviderType} is not implemented in QueuedFileOp.");
                }

                switch (Type)
                {
                case QueuedFileOperationType.DeleteFile:
                    if (!provider.FileExists(TargetPath))
                    {
                        Log.LogErr($"Queued file operation was supposed to delete '{TargetPath}' but it didn't exist!");
                    }
                    else
                    {
                        provider.Delete(TargetPath);
                    }
                    break;

                case QueuedFileOperationType.DeleteFolder:
                    if (!provider.DirectoryExists(TargetPath))
                    {
                        Log.LogErr($"Queued file operation was supposed to delete '{TargetPath}' but it didn't exist!");
                    }
                    else
                    {
                        provider.RmRfDir(TargetPath);
                    }
                    break;

                case QueuedFileOperationType.ExtractZipToFolder:
                    throw new NotImplementedException();

                case QueuedFileOperationType.WriteFile:
                    provider.MkDir(TargetPath.GetDirectoryFwdSlash(), true);
                    provider.Write(TargetPath, SourceData, true);
                    provider.Save();
                    break;
                }
            }
            catch (NotImplementedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Log.LogErr($"Exception handling queued file operation of type {Type}", ex);
                throw;
            }
        }