diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-25 18:11:35 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-25 18:11:35 +0100 |
| commit | 4aba4d7597005af1efa12f420e01d5f938ad60d8 (patch) | |
| tree | 1fbfbffb402f18e54883bddb31780b9581ad5d0d /vfs/UVFSCore.pas | |
| parent | 53c1df30e07af532133db05ee0254f9c1dae66f7 (diff) | |
| download | tuxcmd-4aba4d7597005af1efa12f420e01d5f938ad60d8.tar.xz | |
Clean VFS API up a littlev0.6.69
Strictly split archiving and networking mode, get rid of prefixes
Diffstat (limited to 'vfs/UVFSCore.pas')
| -rw-r--r-- | vfs/UVFSCore.pas | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index 7516544..bf2cd9d 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -31,7 +31,8 @@ type FVFSFree: TVFSFree; FVFSVersion: TVFSVersion; FVFSGetInfo: TVFSGetInfo; - FVFSOpen: TVFSOpen; + FVFSOpenArchive: TVFSOpenArchive; + FVFSOpenURI: TVFSOpenURI; FVFSClose: TVFSClose; FVFSListFirst: TVFSListFirst; FVFSListNext: TVFSListNext; @@ -39,7 +40,6 @@ type FVFSChangeDir: TVFSChangeDir; FVFSGetPath: TVFSGetPath; FVFSGetPathURI: TVFSGetPathURI; - FVFSGetPrefix: TVFSGetPrefix; FVFSGetFileSystemSize: TVFSGetFileSystemSize; FVFSGetFileSystemFree: TVFSGetFileSystemFree; FVFSFileExists: TVFSFileExists; @@ -72,7 +72,7 @@ type function GetHandlesNetwork: boolean; public ModuleHandle: Pointer; - FullPath: string; // module path + FullModulePath: string; // module path Extensions, Services: TOpenStringArray; // the list of the extensions plugin can handle constructor Create(PluginHandle: Pointer); destructor Destroy; override; @@ -94,9 +94,10 @@ type FSourcePlugin: TVFSPlugin; FBlockSize: Cardinal; BreakProcessingKind: integer; + FArchiveMode: boolean; + FArchivePath: string; function GetPluginID: string; public - ArchiveMode: boolean; Password: string; PasswordUsed: boolean; RemoveFileOnClose: string; @@ -140,7 +141,6 @@ type function FileCanRun(const FileName: string): boolean; override; function GetPath: string; override; procedure SetPath(Value: string); override; - function GetPrefix: string; override; function GetPathURI: string; function GetBlockSize: Cardinal; override; @@ -160,6 +160,8 @@ type property Path: string read GetPath write SetPath; property BlockSize: Cardinal read GetBlockSize write SetBlockSize; property PluginID: string read GetPluginID; + property ArchiveMode: boolean read FArchiveMode; + property ArchivePath: string read FArchivePath; end; @@ -204,7 +206,8 @@ begin @FVFSFree := dlsym(ModuleHandle, 'VFSFree'); @FVFSVersion := dlsym(ModuleHandle, 'VFSVersion'); @FVFSGetInfo := dlsym(ModuleHandle, 'VFSGetInfo'); - @FVFSOpen := dlsym(ModuleHandle, 'VFSOpen'); + @FVFSOpenArchive := dlsym(ModuleHandle, 'VFSOpenArchive'); + @FVFSOpenURI := dlsym(ModuleHandle, 'VFSOpenURI'); @FVFSClose := dlsym(ModuleHandle, 'VFSClose'); @FVFSListFirst := dlsym(ModuleHandle, 'VFSListFirst'); @FVFSListNext := dlsym(ModuleHandle, 'VFSListNext'); @@ -212,7 +215,6 @@ begin @FVFSGetPath := dlsym(ModuleHandle, 'VFSGetPath'); @FVFSGetPathURI := dlsym(ModuleHandle, 'VFSGetPathURI'); @FVFSChangeDir := dlsym(ModuleHandle, 'VFSChangeDir'); - @FVFSGetPrefix := dlsym(ModuleHandle, 'VFSGetPrefix'); @FVFSGetFileSystemSize := dlsym(ModuleHandle, 'VFSGetFileSystemSize'); @FVFSGetFileSystemFree := dlsym(ModuleHandle, 'VFSGetFileSystemFree'); @FVFSFileExists := dlsym(ModuleHandle, 'VFSFileExists'); @@ -245,14 +247,14 @@ begin // Initialize the extensions list SetLength(Extensions, 0); SetLength(Services, 0); - if @FVFSGetArchiveExts <> nil then begin + if (@FVFSGetArchiveExts <> nil) and (@FVFSOpenArchive <> nil) then begin s := FVFSGetArchiveExts; if s <> nil then begin ParseString(String(s), ';', Extensions); real_libc_free(s); end; end; - if @FVFSGetNetworkServices <> nil then begin + if (@FVFSGetNetworkServices <> nil) and (@FVFSOpenURI <> nil) then begin s := FVFSGetNetworkServices; if s <> nil then begin ParseString(String(s), ';', Services); @@ -328,12 +330,12 @@ end; function TVFSPlugin.GetHandlesArchives: boolean; begin - Result := Length(Extensions) > 0; + Result := (Length(Extensions) > 0) and (@FVFSOpenArchive <> nil); end; function TVFSPlugin.GetHandlesNetwork: boolean; begin - Result := Length(Services) > 0; + Result := (Length(Services) > 0) and (@FVFSOpenURI <> nil); end; (********************************************************************************************************************************) @@ -343,7 +345,8 @@ begin inherited Create; FSourcePlugin := SourcePlugin; FBlockSize := 65536; - ArchiveMode := False; + FArchiveMode := False; + FArchivePath := ''; BreakProcessingKind := 0; FGlobs := nil; Password := ''; @@ -370,10 +373,12 @@ end; function TVFSEngine.VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; begin Result := False; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) then begin + if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenURI <> nil) then begin if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); - Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(URI)) = cVFS_OK; + Result := FSourcePlugin.FVFSOpenURI(FGlobs, PChar(URI)) = cVFS_OK; + FArchiveMode := False; + FArchivePath := ''; if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; @@ -382,10 +387,13 @@ end; function TVFSEngine.VFSOpenEx(OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult; begin Result := cVFS_OK; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) then begin + if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenArchive <> nil) then begin if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); - Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(OpenFile)); + Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(OpenFile)); + FArchiveMode := True; + if Result = cVFS_OK then FArchivePath := OpenFile + else FArchivePath := ''; if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; @@ -550,19 +558,6 @@ begin FreeDataItem(Item); end; -function TVFSEngine.GetPrefix: string; -var s: PChar; -begin - Result := 'VFS'; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetPrefix <> nil) then begin - s := FSourcePlugin.FVFSGetPrefix(FGlobs); - if s <> nil then begin - Result := String(s); - real_libc_free(s); - end; - end; -end; - function TVFSEngine.GetPath: string; var s: PChar; begin @@ -1128,7 +1123,7 @@ begin b := False; if PluginList.Count > 0 then for i := 0 to PluginList.Count - 1 do - if CompareStr(TVFSPlugin(PluginList[i]).FullPath, IncludeTrailingPathDelimiter(s) + Buf) = 0 then begin + if CompareStr(TVFSPlugin(PluginList[i]).FullModulePath, IncludeTrailingPathDelimiter(s) + Buf) = 0 then begin b := True; Break; end; @@ -1140,7 +1135,7 @@ begin @VFSVersionFunc := dlsym(ModuleHandler, 'VFSVersion'); if (@VFSVersionFunc <> nil) and (VFSVersionFunc = ConstVFSVersionRequired) then begin PluginItem := TVFSPlugin.Create(ModuleHandler); - PluginItem.FullPath := IncludeTrailingPathDelimiter(s) + Buf; + PluginItem.FullModulePath := IncludeTrailingPathDelimiter(s) + Buf; PluginList.Add(PluginItem); end else DebugMsg([' $XXX: Error getting version info or version mismatch']); except end; |
