static int ShortcutMain(Options opts)
{
string root = Path.Combine(Cache.LocalAppData, opts.AppName);
string programPath = opts.ProgramPath;
var status = Normalize.SpecialPath(root, ref programPath);
if (status != null)
return RaiseError(status);
string iconPath = opts.IconPath;
if (iconPath != null)
{
status = Normalize.SpecialPath(root, ref iconPath);
if (status != null)
return RaiseError(status);
}
string contents = @"[InternetShortcut]
URL=file:///" + programPath.Replace('\\', '/'); // TODO: Use $ when VS gets its highlighting straight.
if (iconPath != null)
{
contents += $@"
IconIndex=0
IconFile={iconPath.Replace('\\', '/')}";
}
foreach (string folder in GetShortcutFolders(opts))
{
string file = Path.Combine(folder, $"{opts.AppName}.url");
File.WriteAllText(file, contents);
}
return 0;
}