winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

AppInstallerRuntime.h (3959B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include <AppInstallerVersions.h>
      5 #include <winget/LocIndependent.h>
      6 #include <winget/Filesystem.h>
      7 #include <winget/Runtime.h>
      8 
      9 #include <filesystem>
     10 #include <memory>
     11 #include <string>
     12 #include <string_view>
     13 
     14 namespace AppInstaller::Runtime
     15 {
     16     // Sets the runtime path state name globally.
     17     void SetRuntimePathStateName(std::string name);
     18 
     19     // A path to be retrieved based on the runtime.
     20     enum class PathName
     21     {
     22         // The temporary file location.
     23         Temp,
     24         // The local state (file) storage location.
     25         LocalState,
     26         // The default location where log files are located.
     27         DefaultLogLocation,
     28         // The location that standard type settings are stored.
     29         // In a packaged context, this returns a prepend value for the container name.
     30         StandardSettings,
     31         // The location that user file type settings are stored.
     32         UserFileSettings,
     33         // The location where secure settings data is stored (for reading).
     34         SecureSettingsForRead,
     35         // The location where secure settings data is stored (for writing).
     36         SecureSettingsForWrite,
     37         // The value of %USERPROFILE%.
     38         UserProfile,
     39         // The location where portable packages are installed to with user scope.
     40         PortablePackageUserRoot,
     41         // The location where portable packages are installed to with machine scope.
     42         PortablePackageMachineRoot,
     43         // The location where portable packages are installed to with machine scope (x86).
     44         PortablePackageMachineRootX86,
     45         // The location where symlinks to portable packages are stored under user scope.
     46         PortableLinksUserLocation,
     47         // The location where symlinks to portable packages are stored under machine scope.
     48         PortableLinksMachineLocation,
     49         // The root location for the package containing the winget application.
     50         SelfPackageRoot,
     51         // The location where user downloads are stored.
     52         UserProfileDownloads,
     53         // The location where configuration modules are stored.
     54         ConfigurationModules,
     55         // The location where checkpoints are stored.
     56         CheckpointsLocation,
     57         // The location of the CLI executable file.
     58         CLIExecutable,
     59         // The directory containing the CLI executable file.
     60         MCPExecutable,
     61         // The location of the image assets, if it exists.
     62         ImageAssets,
     63         // The location where fonts are installed with user scope.
     64         FontsUserInstallLocation,
     65         // The location where fonts are installed with machine scope.
     66         FontsMachineInstallLocation,
     67         // Always one more than the last path; for being able to iterate paths in tests.
     68         Max
     69     };
     70 
     71     // Gets the PathDetails used for the given path.
     72     // This is exposed primarily to allow for testing, GetPathTo should be preferred.
     73     Filesystem::PathDetails GetPathDetailsFor(PathName path, bool forDisplay = false);
     74 
     75     // Gets the path to the requested location.
     76     inline std::filesystem::path GetPathTo(PathName path, bool forDisplay = false)
     77     {
     78         return Filesystem::GetPathTo(path, forDisplay);
     79     }
     80 
     81     // Replaces the substring in the path with the user profile environment variable.
     82     void ReplaceProfilePathsWithEnvironmentVariable(std::filesystem::path& path);
     83 
     84     // Gets a new temp file path.
     85     std::filesystem::path GetNewTempFilePath();
     86 
     87     // Determines whether developer mode is enabled.
     88     bool IsDevModeEnabled();
     89 
     90     // Gets the default user agent string for the Windows Package Manager.
     91     Utility::LocIndString GetDefaultUserAgent();
     92 
     93     // Gets the user agent string from passed in caller for the Windows Package Manager.
     94     Utility::LocIndString GetUserAgent(std::string_view caller);
     95 }