Skip to content

Commit

Permalink
LoadPlugin: On Unix use RTLD_NOLOAD to check if library is already lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
ollydev committed Sep 26, 2023
1 parent 87fe930 commit 16e32ac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Source/script/simba.script_pluginloader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ function LoadPlugin(FileName: String; ExtraSearchDirs: TStringArray = nil): TLib
implementation

uses
simba.mufasatypes, simba.env;
simba.mufasatypes, simba.env
{$IFDEF UNIX},
dl
{$ENDIF};

function LoadPlugin(FileName: String; ExtraSearchDirs: TStringArray): TLibHandle;
begin
if (not FindPlugin(FileName, ExtraSearchDirs)) then
raise Exception.CreateFmt('Unable to find plugin "%s"', [FileName]);

{$IFDEF UNIX}
Result := TLibHandle(dlopen(PChar(FileName), RTLD_NOLOAD));
if (Result <> NilHandle) then
Exit;
{$ENDIF}

Result := LoadLibrary(FileName);

if (Result = NilHandle) then
Expand Down

0 comments on commit 16e32ac

Please sign in to comment.