Example #1
0
 private void RecycleCurrentChara()
 {
     if (!string.IsNullOrEmpty(currentCharacter))
     {
         RecycleBinUtil.MoveToRecycleBin(currentCharacter);
         loadedCharacters.Remove(currentCharacter);
         AAA.Logger.LogInfo($"{currentCharacter} moved to the recycle bin.");
         LoadRandomChara();
     }
 }
Example #2
0
        public void DeleteFromDisk(IEnumerable <Mod> mods)
        {
            var paths = mods.Select(mod => mod.Path + (mod.IsEnabled ? null : ".disabled"));

            RecycleBinUtil.Send(paths);

            var names = mods.Select(mod => mod.Id);

            _logService.Info(nameof(ModService), $"Mods deleted:\n{string.Join(", ", names)}");
        }
Example #3
0
        public void DeleteFromDisk(string id, bool isDeleteLibs)
        {
            _logService.Info(nameof(VersionService), $"Deleting version {id}");

            if (_versions.TryGetValue(id, out var versionToDelete))
            {
                _versions.Remove(id);
                Deleted?.Invoke(versionToDelete);

                // Delete version directory
                RecycleBinUtil.Send(Enumerable.Repeat($"{_gamePathService.VersionsDir}/{id}", 1));

                // Delete unused libraries
                if (isDeleteLibs)
                {
                    _logService.Info(nameof(VersionService), $"Deleting version {id} libraries");

                    var libsToDelete = versionToDelete.Libraries as IEnumerable <Library>;

                    if (_versions.Any())
                    {
                        foreach (var version in _versions.Values)
                        {
                            libsToDelete = libsToDelete.Except(version.Libraries);
                        }
                    }

                    var paths = libsToDelete.Select(lib =>
                    {
                        string libPath = $"{_gamePathService.LibrariesDir}/{lib.Path}";

                        if (lib.Type == LibraryType.ForgeMain)
                        {
                            return(Path.GetDirectoryName(libPath));
                        }

                        return(libPath);
                    });

                    RecycleBinUtil.Send(paths);