From 917901e8e33438c425aef50a0a7417f32d77b760 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Mon, 9 Nov 2009 00:27:55 +0000 Subject: merged unicode branch (r1931) into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1939 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UDLLManager.pas | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'src/base/UDLLManager.pas') diff --git a/src/base/UDLLManager.pas b/src/base/UDLLManager.pas index 3faa15bf..d5bb1480 100644 --- a/src/base/UDLLManager.pas +++ b/src/base/UDLLManager.pas @@ -35,7 +35,9 @@ interface uses ModiSDK, - UFiles; + UFiles, + UPath, + UFilesystem; type TDLLMan = class @@ -47,14 +49,14 @@ type P_RData: pModi_RData; public Plugins: array of TPluginInfo; - PluginPaths: array of string; + PluginPaths: array of IPath; Selected: ^TPluginInfo; constructor Create; procedure GetPluginList; procedure ClearPluginInfo(No: cardinal); - function LoadPluginInfo(Filename: string; No: cardinal): boolean; + function LoadPluginInfo(const Filename: IPath; No: cardinal): boolean; function LoadPlugin(No: cardinal): boolean; procedure UnLoadPlugin; @@ -92,7 +94,7 @@ uses {$ELSE} dynlibs, {$ENDIF} - UPath, + UPathUtils, ULog, SysUtils; @@ -107,27 +109,26 @@ end; procedure TDLLMan.GetPluginList; var - SearchRecord: TSearchRec; + Iter: IFileIterator; + FileInfo: TFileInfo; begin - - if FindFirst(PluginPath + '*' + DLLExt, faAnyFile, SearchRecord) = 0 then + Iter := FileSystem.FileFind(PluginPath.Append('*' + DLLExt), 0); + while (Iter.HasNext) do begin - repeat - SetLength(Plugins, Length(Plugins)+1); - SetLength(PluginPaths, Length(Plugins)); + SetLength(Plugins, Length(Plugins)+1); + SetLength(PluginPaths, Length(Plugins)); + + FileInfo := Iter.Next; - if LoadPluginInfo(SearchRecord.Name, High(Plugins)) then // loaded succesful - begin - PluginPaths[High(PluginPaths)] := SearchRecord.Name; - end - else // error loading - begin - SetLength(Plugins, Length(Plugins)-1); - SetLength(PluginPaths, Length(Plugins)); - end; - - until FindNext(SearchRecord) <> 0; - FindClose(SearchRecord); + if LoadPluginInfo(FileInfo.Name, High(Plugins)) then // loaded succesful + begin + PluginPaths[High(PluginPaths)] := FileInfo.Name; + end + else // error loading + begin + SetLength(Plugins, Length(Plugins)-1); + SetLength(PluginPaths, Length(Plugins)); + end; end; end; @@ -164,7 +165,7 @@ begin Plugins[No].EnLineBonus_O := true; end; -function TDLLMan.LoadPluginInfo(Filename: string; No: cardinal): boolean; +function TDLLMan.LoadPluginInfo(const Filename: IPath; No: cardinal): boolean; var hLibg: THandle; Info: pModi_PluginInfo; @@ -182,7 +183,7 @@ begin } // load libary - hLibg := LoadLibrary(PChar(PluginPath + Filename)); + hLibg := LoadLibrary(PChar(PluginPath.Append(Filename).ToNative)); // if loaded if (hLibg <> 0) then begin @@ -197,19 +198,19 @@ begin Result := true; end else - Log.LogError('Could not load plugin "' + Filename + '": Info procedure not found'); + Log.LogError('Could not load plugin "' + Filename.ToNative + '": Info procedure not found'); FreeLibrary (hLibg); end else - Log.LogError('Could not load plugin "' + Filename + '": Libary not loaded'); + Log.LogError('Could not load plugin "' + Filename.ToNative + '": Libary not loaded'); end; function TDLLMan.LoadPlugin(No: cardinal): boolean; begin Result := true; // load libary - hLib := LoadLibrary(PChar(PluginPath + PluginPaths[No])); + hLib := LoadLibrary(PChar(PluginPath.Append(PluginPaths[No]).ToNative)); // if loaded if (hLib <> 0) then begin @@ -226,11 +227,11 @@ begin end else begin - Log.LogError('Could not load plugin "' + PluginPaths[No] + '": Procedures not found'); + Log.LogError('Could not load plugin "' + PluginPaths[No].ToNative + '": Procedures not found'); end; end else - Log.LogError('Could not load plugin "' + PluginPaths[No] + '": Libary not loaded'); + Log.LogError('Could not load plugin "' + PluginPaths[No].ToNative + '": Libary not loaded'); end; procedure TDLLMan.UnLoadPlugin; -- cgit v1.2.3