Skip to content

Commit

Permalink
Rename file in single portable installs
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Aug 29, 2023
1 parent b1c432f commit 6e4ee36
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/AppInstallerCLICore/Workflows/PortableFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace AppInstaller::CLI::Workflow
for (const auto& nestedInstallerFile : nestedInstallerFiles)
{
const std::filesystem::path& targetPath = targetInstallDirectory / ConvertToUTF16(nestedInstallerFile.RelativeFilePath);

std::filesystem::path commandAlias;
if (nestedInstallerFile.PortableCommandAlias.empty())
{
Expand All @@ -215,31 +215,20 @@ namespace AppInstaller::CLI::Workflow
{
std::string_view renameArg = context.Args.GetArg(Execution::Args::Type::Rename);
const std::vector<string_t>& commands = context.Get<Execution::Data::Installer>()->Commands;
std::filesystem::path fileName;
std::filesystem::path commandAlias;

if (!renameArg.empty())
std::filesystem::path commandAlias = installerPath.filename();

if (!commands.empty())
{
fileName = commandAlias = ConvertToUTF16(renameArg);
commandAlias = ConvertToUTF16(commands[0]);
}
else
{
if (!commands.empty())
{
commandAlias = ConvertToUTF16(commands[0]);
}
else
{
commandAlias = installerPath.filename();
}

fileName = installerPath.filename();
if (!renameArg.empty())
{
commandAlias = ConvertToUTF16(renameArg);
}

AppInstaller::Filesystem::AppendExtension(fileName, ".exe");
AppInstaller::Filesystem::AppendExtension(commandAlias, ".exe");

const std::filesystem::path& targetFullPath = targetInstallDirectory / fileName;
const std::filesystem::path& targetFullPath = targetInstallDirectory / commandAlias;
entries.emplace_back(std::move(PortableFileEntry::CreateFileEntry(installerPath, targetFullPath, {})));
entries.emplace_back(std::move(PortableFileEntry::CreateSymlinkEntry(symlinkDirectory / commandAlias, targetFullPath)));
}
Expand Down

0 comments on commit 6e4ee36

Please sign in to comment.