// ReSharper disable once SuggestBaseTypeForParameter
        public PendingDirectory(InstallationDirectory installationDirectory, SystemClock clock)
        {
            _pendingLocation = installationDirectory.GetChildDirectory(LocationExtensions.Pending);
            _pendingLocation.EnsureExists();

            _clock = clock;
        }
        public FileBasedGlobalConfiguration(DefaultsConfiguration defaults, FileSystem fileSystem, NuConventions conventions, InstallationDirectory install)
            : base(fileSystem, PathToMe(install, conventions))
        {
            Defaults = defaults;

            OnMissing = GetDefaultConfigurationValue;
            _conventions = conventions;
        }
        public DummyInventoryManager(InstallationDirectory installationDirectory)
        {
            _installationDirectory = installationDirectory;

            _sampleData = _installationDirectory
                .GetChildDirectory("bin")
                .GetChildDirectory("Integration")
                .GetChildDirectory("JDE")
                .GetChildDirectory("SampleData");
        }
示例#4
0
        public virtual async Task <bool> DeleteFilesAsync(List.TaskInfo currentTask = null)
        {
            try
            {
                Parallel.ForEach(GetFileList(), currentFile =>
                {
                    try
                    {
                        currentTask?.mre.WaitOne();

                        currentFile.Refresh();
                        if (!currentFile.Exists)
                        {
                            return;
                        }

                        if (currentTask != null)
                        {
                            currentTask.mre.WaitOne();

                            currentTask.TaskStatusInfo = Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.TaskStatus_DeletingFile)), new { FileName = currentFile.Name, FormattedFileSize = Functions.FileSystem.FormatBytes(currentFile.Length) });

                            if (currentTask.ReportFileMovement)
                            {
                                ReportToTaskManager($"[{DateTime.Now}] [{AppName}] {Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.TaskStatus_DeletingFile)), new { FileName = currentFile.Name, FormattedFileSize = Functions.FileSystem.FormatBytes(currentFile.Length) })}");
                            }
                        }

                        System.IO.File.SetAttributes(currentFile.FullName, System.IO.FileAttributes.Normal);
                        currentFile.Delete();
                    }
                    catch (Exception ex)
                    {
                        Logger.Fatal(ex);
                    }
                });

                InstallationDirectory.Refresh();
                if (InstallationDirectory.Exists)
                {
                    await Task.Run(() => InstallationDirectory.Delete(true));
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(false);
            }
        }
示例#5
0
        public virtual List <FileInfo> GetFileList()
        {
            try
            {
                InstallationDirectory?.Refresh();

                return(InstallationDirectory.Exists ? InstallationDirectory?.GetFiles("*", System.IO.SearchOption.AllDirectories)?.ToList() : null);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
                return(null);
            }
        }
 static File GetMyPath(InstallationDirectory install, NuConventions conventions)
 {
     return install.GetChildFile(conventions.DefaultsFileName);
 }
 public FileBasedDefaultsConfiguration(IFileSystem fileSystem, NuConventions conventions, InstallationDirectory install)
     : base(fileSystem, GetMyPath(install, conventions))
 {
 }
 static File PathToMe(InstallationDirectory install, NuConventions conventions)
 {
     return install.GetChildFile(conventions.ConfigurationFileName);
 }
示例#9
0
 public FileBasedLocalCatalogue(IFileSystem fileSystem, InstallationDirectory installLocation)
 {
     _fileSystem = fileSystem;
     _file = installLocation.GetChildFile("catalogue.json");
     RemoteCatalogues = ReadExistingDataFromFile(_file);
 }
        public override async void ParseMenuItemActionAsync(string action)
        {
            try
            {
                switch (action.ToLowerInvariant())
                {
                default:
                    if (AppId != 0)
                    {
                        Process.Start(string.Format(action, AppId));
                    }

                    break;

                case "disk":
                    InstallationDirectory.Refresh();

                    if (InstallationDirectory.Exists)
                    {
                        Process.Start(InstallationDirectory.FullName);
                    }

                    break;

                case "install":
                    await InstallAsync();

                    break;

                case "compress":
                    if (Functions.TaskManager.TaskList.Count(x => x.App == this && x.TargetLibrary == Library && x.TaskType == Enums.TaskType.Compress) == 0)
                    {
                        Functions.TaskManager.AddTask(new List.TaskInfo
                        {
                            App           = this,
                            TargetLibrary = Library,
                            TaskType      = Enums.TaskType.Compress,
                            Compress      = !IsCompressed
                        });
                    }
                    break;

                case "compact":
                    if (Functions.TaskManager.TaskList.Count(x => x.App == this && x.TargetLibrary == Library && x.TaskType == Enums.TaskType.Compact) == 0)
                    {
                        Functions.TaskManager.AddTask(new List.TaskInfo
                        {
                            App           = this,
                            TargetLibrary = Library,
                            TaskType      = Enums.TaskType.Compact
                        });
                    }
                    break;

                case "deleteappfiles":
                    await Task.Run(async() => await DeleteFilesAsync()).ConfigureAwait(false);

                    Library.Apps.Remove(this);
                    if (SLM.CurrentSelectedLibrary == Library)
                    {
                        Functions.App.UpdateAppPanel(Library);
                    }

                    break;

                case "deleteappfilestm":
                    Functions.TaskManager.AddTask(new List.TaskInfo
                    {
                        App           = this,
                        TargetLibrary = Library,
                        TaskType      = Enums.TaskType.Delete
                    });
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
    static void SetupCompileEditorTools(NPath rootPath)
    {
        // since this target and `get-editor-tools` target outputs the same files
        // we cannot have these two targets side by side in the dag.
        // We need this to generate the only correct target
        if (!CompileEditorToolsFromSourceFileFlag.FileExists())
        {
            return;
        }

        var editorToolsSourceDirectory = rootPath.Combine("EditorTools/Src");
        var env = new Dictionary <string, string>()
        {
            { "PATH", $"{NodeDirectory.ToString()}{PathSeparator}{Environment.GetEnvironmentVariable("PATH")}" }
        };
        var dependencies = new List <NPath>();

        // Iterate all folders in Tools and process them
        foreach (var toolDir in editorToolsSourceDirectory.Contents())
        {
            if (toolDir.FileExists("package.json"))
            {
                var packageLockJsonFilePath = toolDir.Combine("package-lock.json");
                var packageJsonFilePath     = toolDir.Combine("package.json");

                // Run npm install
                Backend.Current.AddAction($"npm install",
                                          targetFiles: new[] { packageLockJsonFilePath },
                                          inputs: new[] { Node.Path, packageJsonFilePath },
                                          executableStringFor: $"cd {toolDir.InQuotes()} && npm install",
                                          commandLineArguments: Array.Empty <string>(),
                                          environmentVariables: env,
                                          allowUnwrittenOutputFiles: true);

                dependencies.Add(packageLockJsonFilePath);

                // Run package
                var inputs = new List <NPath>
                {
                    Node.Path,
                    packageLockJsonFilePath
                };

                var indexJsNotInModules = toolDir.Files("index.js", true).Where(p => !p.IsChildOf(toolDir.Combine("node_modules")));
                inputs.AddRange(indexJsNotInModules);
                var toolInstallDir = InstallationDirectory.Combine(toolDir.FileName);

                Backend.Current.AddAction($"package",
                                          targetFiles: new[] { toolInstallDir.Combine($"DotsEditorTools-win.exe"), toolInstallDir.Combine($"DotsEditorTools-macos") },
                                          inputs: inputs.ToArray(),
                                          executableStringFor: $"cd {toolDir.InQuotes()} && npm run package -- --out-path {toolInstallDir.InQuotes()} --targets win-x64,macos-x64 .",
                                          commandLineArguments: Array.Empty <string>(),
                                          environmentVariables: env,
                                          allowUnwrittenOutputFiles: true);

                dependencies.Add(toolInstallDir.Combine($"DotsEditorTools-win.exe"));
                dependencies.Add(toolInstallDir.Combine($"DotsEditorTools-macos"));
            }
            else // Not a node tool, just copy files recursively
            {
                foreach (var file in toolDir.Files(true))
                {
                    if (file.FileName == "extrabeetmpfile")
                    {
                        continue;
                    }

                    var target = file.ToString().Replace(editorToolsSourceDirectory.ToString(), InstallationDirectory.ToString());
                    CopyTool.Instance().Setup(target, file);
                    dependencies.Add(target);
                }
            }
        }

        Backend.Current.AddAliasDependency("compile-editor-tools", dependencies.ToArray());
    }
    static void SetupGetEditorToolsFromStevedore()
    {
        // since this target and `get-editor-tools` target outputs the same files
        // we cannot have these two targets side by side in the dag.
        // We need this to generate the only correct target
        if (CompileEditorToolsFromSourceFileFlag.FileExists())
        {
            return;
        }

        var executablesFromEditorTools = new HashSet <string>
        {
            "artifacts/Stevedore/dots-editor-tools/images/osx/cwebp",
            "artifacts/Stevedore/dots-editor-tools/images/osx/moz-cjpeg",
            "artifacts/Stevedore/dots-editor-tools/images/osx/pngcrush",
            "artifacts/Stevedore/dots-editor-tools/manager/DotsEditorTools-macos",
        };

        var EditorTools = new StevedoreArtifact("dots-editor-tools");

        var dependencies = new List <NPath>();

        foreach (var file in EditorTools.GetFileList())
        {
            var target = new NPath(file.ToString().Replace(EditorTools.Path.ToString(), InstallationDirectory.ToString()));

            if ((HostPlatform.IsOSX || HostPlatform.IsLinux) && executablesFromEditorTools.Contains(file.ToString()))
            {
                Backend.Current.AddAction("copy and chmod +x", new[] { target }, new[] { file }, $"cp {file.InQuotes()} {target.InQuotes()} && chmod +x {target.InQuotes()}", Array.Empty <string>());
            }
            else
            {
                CopyTool.Instance().Setup(target, file);
            }

            dependencies.Add(target);
        }

        Backend.Current.AddAliasDependency("get-editor-tools", dependencies.ToArray());
    }
示例#13
0
        public async void ParseMenuItemActionAsync(string action)
        {
            try
            {
                switch (action.ToLowerInvariant())
                {
                default:
                    if (string.IsNullOrEmpty(Properties.Settings.Default.SteamID64))
                    {
                        return;
                    }

                    Process.Start(string.Format(action, AppId, Properties.Settings.Default.SteamID64));
                    break;

                case "compress":
                    if (Functions.TaskManager.TaskList.Count(x => x.SteamApp == this && x.TargetLibrary == Library && x.TaskType == Enums.TaskType.Compress && !x.Completed) == 0)
                    {
                        Functions.TaskManager.AddTask(new List.TaskInfo
                        {
                            SteamApp      = this,
                            TargetLibrary = Library,
                            Compress      = !IsCompressed,
                            TaskType      = Enums.TaskType.Compress
                        });
                    }
                    break;

                case "compact":
                    if (Functions.TaskManager.TaskList.Count(x => x.SteamApp == this && x.TargetLibrary == Library && x.TaskType == Enums.TaskType.Compact && !x.Completed) == 0)
                    {
                        Functions.TaskManager.AddTask(new List.TaskInfo
                        {
                            SteamApp      = this,
                            TargetLibrary = Library,
                            TaskType      = Enums.TaskType.Compact
                        });
                    }
                    break;

                case "disk":
                    InstallationDirectory.Refresh();

                    if (InstallationDirectory.Exists)
                    {
                        Process.Start(InstallationDirectory.FullName);
                    }

                    break;

                case "acffile":
                    FullAcfPath.Refresh();

                    if (FullAcfPath.Exists)
                    {
                        Process.Start(FullAcfPath.FullName);
                    }
                    break;

                case "deleteappfiles":
                    await Task.Run(() => DeleteFilesAsync()).ConfigureAwait(false);

                    Library.Steam.Apps.Remove(this);
                    Functions.SLM.Library.UpdateLibraryVisual();

                    if (SLM.CurrentSelectedLibrary == Library)
                    {
                        Functions.App.UpdateAppPanel(Library);
                    }
                    break;

                case "deleteappfilestm":
                    Functions.TaskManager.AddTask(new List.TaskInfo
                    {
                        SteamApp      = this,
                        TargetLibrary = Library,
                        TaskType      = Enums.TaskType.Delete
                    });
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
            }
        }
 public ArchiveDirectory(InstallationDirectory installationDirectory)
 {
     _location = installationDirectory.GetChildDirectory(LocationExtensions.Archive);
     _location.EnsureExists();
 }
示例#15
0
 public DotNetNugsDirectory(InstallationDirectory directory, NuConventions conventions)
     : base(directory.GetChildDirectory(conventions.NugsDirectoryName).Name)
 {
 }
 public ReadyDirectory(InstallationDirectory installationDirectory, SystemClock clock)
 {
     _readyLocation = installationDirectory.GetChildDirectory(LocationExtensions.Ready);
     _readyLocation.EnsureExists();
     _clock = clock;
 }
示例#17
0
 public AddToPathCommand(InstallationDirectory installPoint)
 {
     _installPoint = installPoint;
 }