You've already forked lazarus-ccr
To V0.3.5.0. Shortcut code working in Windows and Linux
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5721 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,11 +4,11 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Linux64"/>
|
||||
<Units Count="31">
|
||||
<Units Count="34">
|
||||
<Unit0>
|
||||
<Filename Value="testapp.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<EditorIndex Value="11"/>
|
||||
<CursorPos X="25" Y="28"/>
|
||||
<UsageCount Value="94"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -19,8 +19,8 @@
|
||||
<ComponentName Value="mainform"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<TopLine Value="208"/>
|
||||
<CursorPos X="66" Y="220"/>
|
||||
<TopLine Value="177"/>
|
||||
<CursorPos X="36" Y="181"/>
|
||||
<UsageCount Value="94"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -42,15 +42,15 @@
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="44"/>
|
||||
<CursorPos X="63" Y="61"/>
|
||||
<ExtraEditorCount Value="2"/>
|
||||
<ExtraEditor1>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<WindowIndex Value="1"/>
|
||||
<TopLine Value="1707"/>
|
||||
<CursorPos X="44" Y="1747"/>
|
||||
<ExtraEditorCount Value="2"/>
|
||||
<ExtraEditor1>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="44"/>
|
||||
<CursorPos X="63" Y="61"/>
|
||||
</ExtraEditor1>
|
||||
<ExtraEditor2>
|
||||
<EditorIndex Value="-1"/>
|
||||
@ -186,9 +186,9 @@
|
||||
<Unit22>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="219"/>
|
||||
<CursorPos X="87" Y="240"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<TopLine Value="179"/>
|
||||
<CursorPos X="9" Y="221"/>
|
||||
<UsageCount Value="36"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit22>
|
||||
@ -201,7 +201,7 @@
|
||||
</Unit23>
|
||||
<Unit24>
|
||||
<Filename Value="C:\laztrunk\fpc\packages\winunits-base\src\shlobj.pp"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<EditorIndex Value="10"/>
|
||||
<TopLine Value="2203"/>
|
||||
<CursorPos X="56" Y="2335"/>
|
||||
<UsageCount Value="25"/>
|
||||
@ -210,8 +210,8 @@
|
||||
<Unit25>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\classesh.inc"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="399"/>
|
||||
<CursorPos X="30" Y="426"/>
|
||||
<TopLine Value="662"/>
|
||||
<CursorPos X="25" Y="697"/>
|
||||
<UsageCount Value="24"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit25>
|
||||
@ -239,144 +239,168 @@
|
||||
</Unit28>
|
||||
<Unit29>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\sysutils\finah.inc"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<CursorPos X="10" Y="33"/>
|
||||
<EditorIndex Value="9"/>
|
||||
<CursorPos X="38" Y="36"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit29>
|
||||
<Unit30>
|
||||
<Filename Value="C:\laztrunk\lazarus\components\lazutils\lazfileutils.pas"/>
|
||||
<UnitName Value="LazFileUtils"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<TopLine Value="273"/>
|
||||
<CursorPos X="3" Y="278"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<TopLine Value="58"/>
|
||||
<CursorPos X="29" Y="87"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit30>
|
||||
<Unit31>
|
||||
<Filename Value="C:\laztrunk\fpc\packages\rtl-objpas\src\inc\strutils.pp"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<TopLine Value="1809"/>
|
||||
<CursorPos X="3" Y="1812"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit31>
|
||||
<Unit32>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\stringl.inc"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="1110"/>
|
||||
<CursorPos X="10" Y="1116"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit32>
|
||||
<Unit33>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\sysutils\sysencodingh.inc"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<TopLine Value="10"/>
|
||||
<CursorPos X="24" Y="104"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit33>
|
||||
</Units>
|
||||
<OtherDefines Count="1">
|
||||
<Define0 Value="DEBUGMODE"/>
|
||||
</OtherDefines>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="176" Column="4" TopLine="157"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="268" Column="79" TopLine="239"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="170" Column="45" TopLine="159"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="235" Column="60" TopLine="216"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="194" TopLine="170"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="272" Column="25" TopLine="245"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="147" TopLine="145"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="233" Column="47" TopLine="214"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="146" TopLine="144"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="239" Column="20" TopLine="229"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="148" TopLine="146"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="295" Column="31" TopLine="259"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="125" TopLine="108"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="289" Column="22" TopLine="268"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="118" Column="30" TopLine="93"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="278" Column="71" TopLine="268"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="124" Column="45" TopLine="103"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="306" Column="78" TopLine="269"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="125" Column="45" TopLine="104"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="289" Column="57" TopLine="261"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="198" Column="3" TopLine="196"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="255" Column="57" TopLine="229"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="214" Column="56" TopLine="201"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="308" Column="21" TopLine="277"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="216" Column="56" TopLine="203"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="149" Column="39" TopLine="121"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="1004" Column="101" TopLine="970"/>
|
||||
<Caret Line="999" Column="4" TopLine="970"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="268" Column="79" TopLine="239"/>
|
||||
<Caret Line="186" Column="24" TopLine="160"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="235" Column="60" TopLine="216"/>
|
||||
<Caret Line="245" Column="26" TopLine="218"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="272" Column="25" TopLine="245"/>
|
||||
<Caret Line="246" Column="31" TopLine="222"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="233" Column="47" TopLine="214"/>
|
||||
<Caret Line="248" Column="53" TopLine="222"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="239" Column="20" TopLine="229"/>
|
||||
<Caret Line="212" Column="33" TopLine="184"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="295" Column="31" TopLine="259"/>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\stringl.inc"/>
|
||||
<Caret Line="1116" Column="75" TopLine="1116"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="289" Column="22" TopLine="268"/>
|
||||
<Caret Line="287" TopLine="269"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="278" Column="71" TopLine="268"/>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\sysutils\sysencodingh.inc"/>
|
||||
<Caret Line="104" Column="24" TopLine="66"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="306" Column="78" TopLine="269"/>
|
||||
<Caret Line="283" Column="56" TopLine="256"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="289" Column="57" TopLine="261"/>
|
||||
<Caret Line="312" Column="56" TopLine="285"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="255" Column="57" TopLine="229"/>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\stringl.inc"/>
|
||||
<Caret Line="1116" Column="10" TopLine="1110"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="308" Column="21" TopLine="277"/>
|
||||
<Caret Line="283" Column="55" TopLine="256"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="149" Column="39" TopLine="121"/>
|
||||
<Caret Line="212" Column="40" TopLine="185"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="999" Column="4" TopLine="970"/>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="255" Column="75" TopLine="235"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="186" Column="24" TopLine="160"/>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="218" Column="29" TopLine="208"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<Caret Line="245" Column="26" TopLine="218"/>
|
||||
<Caret Line="264" Column="13" TopLine="238"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
|
@ -176,9 +176,10 @@ end;
|
||||
|
||||
procedure Tmainform.cmd_MakeDesktopShortcutClick(Sender: TObject);
|
||||
begin
|
||||
LazAutoUpdate1.ShortCut.ShortCutName:='Test Application';
|
||||
LazAutoUpdate1.ShortCut.ShortCutName:=Application.Title;
|
||||
LazAutoUpdate1.ShortCut.Target:=Application.EXEName;
|
||||
LazAutoUpdate1.ShortCut.IconFilename:=ChangeFileExt(Application.EXEName,'.ico');
|
||||
LazAutoUpdate1.ShortCut.Category:=scUtility;
|
||||
If LazAutoUpdate1.MakeShortCut then
|
||||
ShowMessage('Success! New shortcut is now on your desktop')
|
||||
else
|
||||
|
@ -85,7 +85,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LazUTF8, FileUtil, LazFileUtils
|
||||
{$IFDEF LINUX},process,strutils{$ENDIF}
|
||||
{$IFDEF LINUX}, process, strutils, LazUTF8Classes{$ENDIF}
|
||||
{$IFDEF WINDOWS}, Windows, shlobj {for special folders}, ActiveX,
|
||||
ComObj, ShellAPI{$ENDIF} ;
|
||||
|
||||
@ -107,12 +107,12 @@ begin
|
||||
Result := sDebugString;
|
||||
end;
|
||||
// Builds up a string with linebreaks
|
||||
procedure AddToDebugString(Astring:String);
|
||||
procedure AddToDebugString(Astring: string);
|
||||
begin
|
||||
if (sDebugString = '') then
|
||||
sDebugString:=LineEnding + '* ' + Astring
|
||||
sDebugString := LineEnding + '* ' + Astring
|
||||
else
|
||||
sDebugString:=sDebugString + LineEnding + '* ' + Astring;
|
||||
sDebugString := sDebugString + LineEnding + '* ' + Astring;
|
||||
end;
|
||||
|
||||
{$IFDEF UNIX}
|
||||
@ -169,7 +169,7 @@ begin
|
||||
IObject := CreateComObject(CLSID_ShellLink);
|
||||
ISLink := IObject as IShellLink;
|
||||
IPFile := IObject as IPersistFile;
|
||||
TRY
|
||||
try
|
||||
ISLink.SetPath(PChar(Target));
|
||||
ISLink.SetArguments(PChar(TargetArguments));
|
||||
ISLink.SetWorkingDirectory(PChar(ExtractFilePath(Target)));
|
||||
@ -180,7 +180,7 @@ begin
|
||||
LinkName := IncludeTrailingPathDelimiter(InFolder) + ShortcutName + '.lnk';
|
||||
|
||||
{ Get rid of any existing shortcut first }
|
||||
If Not SysUtils.DeleteFile(LinkName) then
|
||||
if not SysUtils.DeleteFile(LinkName) then
|
||||
AddToDebugString('Could not delete existing link ' + LinkName);
|
||||
{ Create the link }
|
||||
IPFile.Save(PWChar(LinkName), False);
|
||||
@ -197,6 +197,9 @@ end;
|
||||
function CreateDesktopShortCut(Target, TargetArguments, ShortcutName,
|
||||
IconFileName, Category: string): boolean;
|
||||
{
|
||||
* Comprehensive debugging messages in this routine.
|
||||
* So many flavours of Linux.. - if no desktop icon is created then
|
||||
* call GetShortCutDebugString and log the result to a file.
|
||||
IN:
|
||||
Target: Filename with full path
|
||||
TargetArguments: String of arguments
|
||||
@ -209,13 +212,13 @@ OUT:
|
||||
Use function GetShortCutDebugString to get errors as a string
|
||||
}
|
||||
var
|
||||
XdgDesktopStringList: TStrings;
|
||||
XdgDesktopStringList: TStringListUTF8;
|
||||
XdgDesktopFile: string;
|
||||
Aprocess: TProcess;
|
||||
sPathToShare: string;
|
||||
sDesktopFilename:String;
|
||||
sDesktopFilename: string;
|
||||
begin
|
||||
// Suceed by default:
|
||||
// Succeed by default:
|
||||
Result := True;
|
||||
sDebugString := '';
|
||||
// Simple failure checks
|
||||
@ -242,23 +245,38 @@ begin
|
||||
AddToDebugString('Category is blank. Using "Utility"');
|
||||
Category := 'Utility';
|
||||
end;
|
||||
// Make up a compliant filename
|
||||
sDesktopFilename:=Copy2Space(shortcutname);
|
||||
sDesktopFilename:=LeftStr(sDesktopFilename,8);
|
||||
// Make up an 8-character filename
|
||||
sDesktopFilename := DelSpace(shortcutname);
|
||||
sDesktopFilename := LeftStr(sDesktopFilename, 8);
|
||||
sDesktopFilename := LowerCase(sDesktopFilename);
|
||||
AddToDebugString('Desktop filename = ' + sDesktopFilename);
|
||||
// Standard path to DeskTop files
|
||||
sPathToShare := IncludeTrailingPathDelimiter(ExpandFileNameUTF8('~')) +
|
||||
'usr/share/applications' + DirectorySeparator +
|
||||
// IncludeTrailingPathDelimiter(ExpandFileNameUTF8('~')) resolves to '/root/'
|
||||
sPathToShare := '/usr/share/applications' + DirectorySeparator +
|
||||
sDesktopFilename + '.desktop';
|
||||
// Directory check
|
||||
if not DirectoryExistsUTF8('/usr/share/applications') then
|
||||
begin
|
||||
AddToDebugString('Failure: Invalid directory - ' + '/usr/share/applications');
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Temp directory path
|
||||
XdgDesktopFile := IncludeTrailingPathDelimiter(GetTempDir(False)) +
|
||||
sDesktopFilename + '.desktop';
|
||||
|
||||
AddToDebugString('XdgDesktopFile = ' + XdgDesktopFile);
|
||||
AddToDebugString('sPathToShare = ' + sPathToShare);
|
||||
// Directory check
|
||||
if not DirectoryExistsUTF8(GetTempDir(False)) then
|
||||
begin
|
||||
AddToDebugString('Failure: Invalid directory - ' + GetTempDir(False));
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
AddToDebugString('Success: XdgDesktopFile = ' + XdgDesktopFile);
|
||||
AddToDebugString('Success: sPathToShare = ' + sPathToShare);
|
||||
|
||||
// Make up the desktop file
|
||||
XdgDesktopStringList := TStringList.Create;
|
||||
XdgDesktopStringList := TStringListUTF8.Create;
|
||||
try
|
||||
XdgDesktopStringList.Add('[Desktop Entry]');
|
||||
XdgDesktopStringList.Add('Encoding=UTF-8');
|
||||
@ -276,11 +294,15 @@ begin
|
||||
AProcess := TProcess.Create(nil);
|
||||
try
|
||||
try
|
||||
if FileExistsUTF8(XdgDesktopFile) then DeleteFile(XdgDesktopFile);
|
||||
if FileExistsUTF8(XdgDesktopFile) then
|
||||
DeleteFile(XdgDesktopFile);
|
||||
Sleep(100);
|
||||
try
|
||||
XdgDesktopStringList.SaveToFile(XdgDesktopFile);
|
||||
if Not FileExistsUTF8(XdgDesktopFile) then
|
||||
AddToDebugString('XdgDesktopFile wasn''t saved');
|
||||
except
|
||||
if not FileExistsUTF8(XdgDesktopFile) then
|
||||
AddToDebugString('Failure: XdgDesktopFile wasn''t saved');
|
||||
end;
|
||||
if FileExistsUTF8(XdgDesktopFile) then
|
||||
begin
|
||||
Aprocess.Executable := 'xdg-desktop-icon install';
|
||||
@ -289,26 +311,30 @@ begin
|
||||
AProcess.Parameters.Add(XdgDesktopFile);
|
||||
Aprocess.Execute;
|
||||
Sleep(100);
|
||||
AddToDebugString('xdg-desktop-icon install succeeded');
|
||||
end;
|
||||
except
|
||||
// xdg-desktop-icon install failed.
|
||||
Result := False;
|
||||
AddToDebugString('Exception running "xdg-desktop-icon install"');
|
||||
AddToDebugString('Failure: Exception running "xdg-desktop-icon install"');
|
||||
|
||||
// OK. Try usr/share/applications
|
||||
if FileExistsUTF8(sPathToShare) then
|
||||
begin
|
||||
If SysUtils.DeleteFile(sPathToShare) then
|
||||
if SysUtils.DeleteFile(sPathToShare) then
|
||||
AddToDebugString('Successfully deleted existing ' + sPathToShare)
|
||||
else
|
||||
AddToDebugString('Unable to delete existing ' + sPathToShare);
|
||||
AddToDebugString('Failure: Unable to delete existing ' + sPathToShare);
|
||||
end;
|
||||
// Save the stringlist directly to usr/share/applications
|
||||
try
|
||||
XdgDesktopStringList.SaveToFile(sPathToShare);
|
||||
If Not FileExistsUTF8(sPathToShare) then
|
||||
except
|
||||
if not FileExistsUTF8(sPathToShare) then
|
||||
begin
|
||||
Result:=FALSE;
|
||||
AddToDebugString('SaveToFile(' + sPathToShare + ') failed');
|
||||
Result := False;
|
||||
AddToDebugString('Failure: SaveToFile(' + sPathToShare + ') failed');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
@ -316,18 +342,31 @@ begin
|
||||
end;
|
||||
if Result = False then
|
||||
try
|
||||
If (FileExistsUTF8(XdgDesktopFile)) AND (NOT FileExistsUTF8(sPathToShare)) then
|
||||
BEGIN
|
||||
if Not (FileExistsUTF8(XdgDesktopFile)) then
|
||||
AddToDebugString('Unable to locate temporary ' + XdgDesktopFile);
|
||||
if (FileExistsUTF8(XdgDesktopFile)) and (not FileExistsUTF8(sPathToShare)) then
|
||||
begin
|
||||
// Last try to copy file to usr/share/applications
|
||||
if CopyFile(XdgDesktopFile, sPathToShare) then
|
||||
Result := True
|
||||
begin
|
||||
AddToDebugString(Format('Successfully copied %s file to %s',
|
||||
[XdgDesktopFile, sPathToShare]));
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
AddToDebugString(Format('Unable to copy %s file to %s', [XdgDesktopFile, sPathToShare]));
|
||||
AddToDebugString(Format('Unable to copy %s file to %s',
|
||||
[XdgDesktopFile, sPathToShare]));
|
||||
// Temp file is no longer needed....
|
||||
if not SysUtils.DeleteFile(XdgDesktopFile) then
|
||||
AddToDebugString('Unable to delete temporary ' + XdgDesktopFile);
|
||||
end
|
||||
else AddToDebugString('Unable to locate temporary ' + XdgDesktopFile);
|
||||
begin
|
||||
AddToDebugString('Failure: Unable to delete temporary ' + XdgDesktopFile);
|
||||
end;
|
||||
end;
|
||||
if (FileExistsUTF8(sPathToShare)) then
|
||||
begin
|
||||
Result:=true;
|
||||
AddToDebugString('Success: Desktop file - ' + sPathToShare);
|
||||
end;
|
||||
finally
|
||||
// Swallow, let filesystem maintenance clear it up
|
||||
end;
|
||||
|
Reference in New Issue
Block a user