summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-25 18:11:35 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-25 18:11:35 +0100
commit4aba4d7597005af1efa12f420e01d5f938ad60d8 (patch)
tree1fbfbffb402f18e54883bddb31780b9581ad5d0d
parent53c1df30e07af532133db05ee0254f9c1dae66f7 (diff)
downloadtuxcmd-0.6.69.tar.xz
Clean VFS API up a littlev0.6.69
Strictly split archiving and networking mode, get rid of prefixes
-rw-r--r--UConfig.pas5
-rw-r--r--UConnectionProperties.pas2
-rw-r--r--UCore.pas36
-rw-r--r--UCoreUtils.pas8
-rw-r--r--UEngines.pas8
-rw-r--r--UMain.pas31
-rw-r--r--UQuickConnect.pas2
-rw-r--r--USearch.pas4
-rw-r--r--UTestPlugin.pas2
-rw-r--r--vfs/UVFSCore.pas57
-rw-r--r--vfs/uVFSprototypes.pas20
11 files changed, 89 insertions, 86 deletions
diff --git a/UConfig.pas b/UConfig.pas
index 9c5d9b7..a405818 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -25,8 +25,8 @@ uses Classes, ULocale;
resourcestring
ConstAppTitle = 'Tux Commander';
- ConstAboutVersion = '0.6.68-dev';
- ConstAboutBuildDate = '2009-10-24';
+ ConstAboutVersion = '0.6.69-dev';
+ ConstAboutBuildDate = '2009-10-25';
{$IFDEF FPC}
{$INCLUDE fpcver.inc}
@@ -56,7 +56,6 @@ const ConfDefaultNormalItemFGColor = '#000000';
ConstFileListTipsDelay = 400;
ConstFileListTipsDelayNeighbour = 95;
ConstNumPanelColumns = 10;
- ConstPathDelim = '#';
ConstFullPathFormatStr = '%s#%s';
ConstConnMgrXORKey = 65;
diff --git a/UConnectionProperties.pas b/UConnectionProperties.pas
index edf6927..7b9ef1b 100644
--- a/UConnectionProperties.pas
+++ b/UConnectionProperties.pas
@@ -194,7 +194,7 @@ begin
MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
MenuItem.Data := PluginList[i];
MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
PluginOptionMenu.Items.Add(MenuItem);
end;
diff --git a/UCore.pas b/UCore.pas
index 5481bf9..dd9cd9e 100644
--- a/UCore.pas
+++ b/UCore.pas
@@ -972,17 +972,29 @@ var DefResponse: integer; // Global variables for this function
function IsOnSameFS(SrcPath, DestPath: string): boolean;
begin
-// DebugMsg(['### IsOnSameFS: "', SrcPath, '" vs. "', DestPath, '"'#10'## Prefix = "', SenderThread.SrcEngine.GetPrefix, '" vs. "', SenderThread.DestEngine.GetPrefix, '"']);
- with SenderThread do
- if SrcEngine.GetPrefix <> DestEngine.GetPrefix
- then Result := False
- else Result := DestEngine.IsOnSameFS(SrcPath, DestPath);
+ with SenderThread do begin
+ if (SrcEngine.ClassName <> DestEngine.ClassName) then Result := False else
+ if (SrcEngine is TVFSEngine) and (DestEngine is TVFSEngine) and
+ (SrcEngine as TVFSEngine).ArchiveMode and (DestEngine as TVFSEngine).ArchiveMode and
+ ((SrcEngine as TVFSEngine).ArchivePath <> '') and
+ ((SrcEngine as TVFSEngine).ArchivePath = (DestEngine as TVFSEngine).ArchivePath)
+ then Result := True else
+ Result := DestEngine.IsOnSameFS(SrcPath, DestPath);
+ end;
end;
function TwoSameFiles(Path1, Path2: string; TestCaseInsensitiveFS: boolean): boolean;
begin
with SenderThread do begin
- if SrcEngine.GetPrefix <> DestEngine.GetPrefix then Result := False else
+ if (SrcEngine.ClassName <> DestEngine.ClassName) then Result := False else
+ if (SrcEngine is TVFSEngine) and (DestEngine is TVFSEngine) and
+ ((SrcEngine as TVFSEngine).ArchiveMode <> (DestEngine as TVFSEngine).ArchiveMode)
+ then Result := False else
+ if (SrcEngine is TVFSEngine) and (DestEngine is TVFSEngine) and
+ (SrcEngine as TVFSEngine).ArchiveMode and (DestEngine as TVFSEngine).ArchiveMode and
+ ((SrcEngine as TVFSEngine).ArchivePath <> '') and
+ ((SrcEngine as TVFSEngine).ArchivePath <> (DestEngine as TVFSEngine).ArchivePath)
+ then Result := False else
if WideCompareStr(Path1, Path2) = 0 then Result := True else
Result := TestCaseInsensitiveFS and DestEngine.TwoSameFiles(Path1, Path2);
end;
@@ -1330,10 +1342,13 @@ begin
PDataItemSL(List[i])^.IsDir and (not PDataItemSL(List[i])^.IsLnk));
// DebugMsg(['s2 = ', Copy(PDataItemSL(List[i])^.AName, Length(CurrPath) + 1, Length(PDataItemSL(List[i])^.AName) - Length(CurrPath)), ', s = ', s]);
end;
- if SrcEngine is TVFSEngine then UpdateCaption1(Format(LANGFromS, [Format(ConstFullPathFormatStr, [SrcEngine.GetPrefix, string(PDataItemSL(List[i])^.FDisplayName)])]))
- else UpdateCaption1(Format(LANGFromS, [string(PDataItemSL(List[i])^.FDisplayName)]));
- if DestEngine is TVFSEngine then UpdateCaption2(Format(LANGToS, [Format(ConstFullPathFormatStr, [DestEngine.GetPrefix, StrToUTF8(s)])]))
- else UpdateCaption2(Format(LANGToS, [StrToUTF8(s)]));
+
+ if not (SrcEngine is TVFSEngine) then UpdateCaption1(Format(LANGFromS, [string(PDataItemSL(List[i])^.FDisplayName)])) else
+ if (SrcEngine as TVFSEngine).ArchiveMode then UpdateCaption1(Format(LANGFromS, [Format(ConstFullPathFormatStr, [(SrcEngine as TVFSEngine).ArchivePath, string(PDataItemSL(List[i])^.FDisplayName)])]))
+ else UpdateCaption1(Format(LANGFromS, [GetURIPrefix((SrcEngine as TVFSEngine).GetPathURI) + StrToUTF8(string(PDataItemSL(List[i])^.FDisplayName))]));
+ if not (DestEngine is TVFSEngine) then UpdateCaption2(Format(LANGToS, [StrToUTF8(s)])) else
+ if (DestEngine as TVFSEngine).ArchiveMode then UpdateCaption2(Format(LANGToS, [Format(ConstFullPathFormatStr, [(DestEngine as TVFSEngine).ArchivePath, StrToUTF8(s)])]))
+ else UpdateCaption2(Format(LANGToS, [GetURIPrefix((DestEngine as TVFSEngine).GetPathURI) + StrToUTF8(s)]));
CommitGUIUpdate;
if TwoSameFiles(s, string(PDataItemSL(List[i])^.FName), ParamBool3) and (not PDataItemSL(List[i])^.IsDir) then begin
FCancelMessage := LANGCannotCopyFileToItself;
@@ -2958,7 +2973,6 @@ begin
if APlugin <> nil then begin
xEngine := TVFSEngine.Create(APlugin);
xEngine.ParentEngine := AEngine;
- xEngine.ArchiveMode := True;
AEngine.LastHighlightItem := AHighlightItem;
xEngine.SavePath := AEngine.Path;
// AEngine must be set here since VFSOpenEx callbacks will reference it
diff --git a/UCoreUtils.pas b/UCoreUtils.pas
index 02cb4e5..c7d7911 100644
--- a/UCoreUtils.pas
+++ b/UCoreUtils.pas
@@ -101,6 +101,7 @@ function URIHidePassword(const SrcURI: string): string;
function UnEscapeURI(const Str: string): string;
function EscapeURI(const Str: string; const IllegalChars: string): string;
function URIRipPassword(var URI: string; const RemovePassword: boolean): string;
+function GetURIPrefix(const URI: string): string;
function StrTotimetDef(const S: string; const Default: time_t): time_t;
@@ -1130,6 +1131,13 @@ begin
if RemovePassword then Delete(URI, PasswordStart, LoginEnd - PasswordStart);
end;
+function GetURIPrefix(const URI: string): string;
+begin
+ if Pos('://', URI) > 0
+ then Result := Copy(URI, 1, Pos('://', URI) + 2)
+ else Result := '';
+end;
+
(********************************************************************************************************************************)
procedure DebugMsg(Params: array of const);
var
diff --git a/UEngines.pas b/UEngines.pas
index 264740c..dd35d44 100644
--- a/UEngines.pas
+++ b/UEngines.pas
@@ -112,7 +112,6 @@ type
function FileCanRun(const FileName: string): boolean; virtual; abstract;
function GetPath: string; virtual; abstract;
procedure SetPath(Value: string); virtual; abstract;
- function GetPrefix: string; virtual; abstract;
// Copy-related routines
function GetBlockSize: guint32; virtual; abstract;
@@ -164,7 +163,6 @@ type
function FileCanRun(const FileName: string): boolean; override;
function GetPath: string; override;
procedure SetPath(Value: string); override;
- function GetPrefix: string; override;
function GetBlockSize: guint32; override;
procedure SetBlockSize(Value: guint32); override;
@@ -1071,12 +1069,6 @@ begin
end;
(********************************************************************************************************************************)
-function TLocalTreeEngine.GetPrefix: string;
-begin
- Result := '';
-end;
-
-(********************************************************************************************************************************)
function TLocalTreeEngine.TwoSameFiles(const Path1, Path2: string): boolean;
var st1, st2: Pstat64;
begin
diff --git a/UMain.pas b/UMain.pas
index 1e46215..057dd3a 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -204,6 +204,7 @@ type
procedure UpdatePanelInfo;
procedure UpdatePanelInfoDown(LeftPanel: boolean);
procedure UpdateCaption;
+ function FormatPathString(Engine: TPanelEngine): string;
procedure ChangingDir(LeftPanel: boolean; NewPath: string; HiliString1: string = ''; HiliString2: string = ''; const PreserveSelection: boolean = False; const AutoFallback: boolean = False; Plugin: TVFSPlugin = nil);
procedure DoSelect(SelectType: integer);
procedure ListViewCellDataFunc(Sender: TObject; tree_view: PGtkTreeView; tree_column : PGtkTreeViewColumn; cell : PGtkCellRenderer; tree_model : PGtkTreeModel; iter : PGtkTreeIter);
@@ -1724,7 +1725,7 @@ begin
if not HandleVFSArchive(LeftPanel, IncludeTrailingPathDelimiter(Engine.Path) + String(Data^.FName), String(Data^.FName), '/') then
if (not ConfUseURI) or ((Engine is TVFSEngine) and TVFSEngine(Engine).ArchiveMode)
then RunFile(IncludeTrailingPathDelimiter(Engine.Path) + String(Data^.FName), Engine, -1)
- else RunFile(ExcludeTrailingPathDelimiter(Engine.GetPrefix) + IncludeTrailingPathDelimiter(Engine.Path) + String(Data^.FName), Engine, -1);
+ else RunFile(IncludeTrailingPathDelimiter((Engine as TVFSEngine).GetPathURI) + String(Data^.FName), Engine, -1);
end;
end;
@@ -1957,9 +1958,15 @@ begin
ChangingDir(LeftPanel, Engine.Path, s1, s2, StaySame, AutoFallback);
end;
+function TFMain.FormatPathString(Engine: TPanelEngine): string;
+begin
+ if not (Engine is TVFSEngine) then Result := Engine.Path else
+ if (Engine as TVFSEngine).ArchiveMode then Result := Format(ConstFullPathFormatStr, [(Engine as TVFSEngine).ArchivePath, Engine.Path])
+ else Result := (Engine as TVFSEngine).GetPathURI;
+end;
+
procedure TFMain.UpdateCaption;
var LeftPanel: boolean;
- s: string;
Engine: TPanelEngine;
begin
if LeftListView.Focused then LeftPanel := True else
@@ -1969,9 +1976,7 @@ begin
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
- if Engine.GetPrefix <> '' then s := Format(ConstFullPathFormatStr, [Engine.GetPrefix, Engine.Path])
- else s := Engine.Path;
- Caption := Format('Tux Commander [%s]', [StrToUTF8(s)]);
+ Caption := Format('Tux Commander [%s]', [StrToUTF8(FormatPathString(Engine))]);
miVerifyChecksums.Enabled := Engine is TLocalTreeEngine;
miCreateChecksums.Enabled := Engine is TLocalTreeEngine;
@@ -1986,12 +1991,8 @@ var FSFree, FSSize: Int64;
begin
UpdateCaption;
Time1 := Now;
- if LeftPanelEngine.GetPrefix <> ''
- then LeftPathLabel.Caption := StrToUTF8(Format(ConstFullPathFormatStr, [LeftPanelEngine.GetPrefix, LeftPanelEngine.Path]))
- else LeftPathLabel.Caption := StrToUTF8(LeftPanelEngine.Path);
- if RightPanelEngine.GetPrefix <> ''
- then RightPathLabel.Caption := StrToUTF8(Format(ConstFullPathFormatStr, [RightPanelEngine.GetPrefix, RightPanelEngine.Path]))
- else RightPathLabel.Caption := StrToUTF8(RightPanelEngine.Path);
+ LeftPathLabel.Caption := StrToUTF8(FormatPathString(LeftPanelEngine));
+ RightPathLabel.Caption := StrToUTF8(FormatPathString(RightPanelEngine));
LeftPathLabel.UseMarkup := True;
RightPathLabel.UseMarkup := True;
if LeftLastFocused then s := LeftPathLabel.Caption
@@ -2016,7 +2017,7 @@ begin
LeftDiskInfoLabel.UseMarkup := True;
RightDiskInfoLabel.UseMarkup := True;
- // Update the visibility of VFS buttons
+ // Update visibility of VFS buttons
LeftDisconnectButton.Visible := (LeftPanelEngine is TVFSEngine) and (not TVFSEngine(LeftPanelEngine).ArchiveMode);
LeftLeaveArchiveButton.Visible := (LeftPanelEngine is TVFSEngine) and TVFSEngine(LeftPanelEngine).ArchiveMode;
RightDisconnectButton.Visible := (RightPanelEngine is TVFSEngine) and (not TVFSEngine(RightPanelEngine).ArchiveMode);
@@ -4495,7 +4496,9 @@ begin
Engine := RightPanelEngine;
AListView := RightListView;
end;
- FileName := IncludeTrailingPathDelimiter(Engine.Path);
+ if ConfUseURI and ((Engine is TVFSEngine) and (not (Engine as TVFSEngine).ArchiveMode))
+ then FileName := IncludeTrailingPathDelimiter((Engine as TVFSEngine).GetPathURI)
+ else FileName := IncludeTrailingPathDelimiter(Engine.Path);
if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir)
then FileName := FileName + PDataItem(AListView.Selected.Data)^.FName;
ShortFName := ExtractFileName(ExcludeTrailingPathDelimiter(FileName));
@@ -4504,8 +4507,6 @@ begin
DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName]);
Exit;
end;
- if ConfUseURI and ((Engine is TVFSEngine) and (not TVFSEngine(Engine).ArchiveMode))
- then FileName := ExcludeTrailingPathDelimiter(Engine.GetPrefix) + FileName;
case Integer((Sender as TGTKMenuItem).Data) of
1: if DataItem^.IsDir then ActivateItem(AListView.Selected.Index)
diff --git a/UQuickConnect.pas b/UQuickConnect.pas
index 2779826..e6d7d5f 100644
--- a/UQuickConnect.pas
+++ b/UQuickConnect.pas
@@ -152,7 +152,7 @@ begin
MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
MenuItem.Data := PluginList[i];
MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
PluginOptionMenu.Items.Add(MenuItem);
end;
diff --git a/USearch.pas b/USearch.pas
index 808027d..d59db48 100644
--- a/USearch.pas
+++ b/USearch.pas
@@ -594,7 +594,6 @@ begin
if b then begin
DebugMsg(['Found plugin ''', Plugin.ModuleID, ''', trying to open the archive ''', archive, '''']);
AEngine := TVFSEngine.Create(Plugin);
- (AEngine as TVFSEngine).ArchiveMode := True;
b := b and ((AEngine as TVFSEngine).VFSOpenEx(archive, nil, nil, nil, nil) = 0);
end;
end;
@@ -803,7 +802,7 @@ begin
ListItem := FileList.Items.Add;
ListItem.SetValue(0, FSearchThread.FList[i]);
if PDataItem(FSearchThread.FList[i])^.LnkPointTo <> nil
- then ListItem.SetValue(1, Format('%s%s%s', [StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.LnkPointTo)), ConstPathDelim, StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.FDisplayName))]))
+ then ListItem.SetValue(1, Format(ConstFullPathFormatStr, [StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.LnkPointTo)), StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.FDisplayName))]))
else ListItem.SetValue(1, StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.FDisplayName)));
if i mod 30 = 0 then Application.ProcessMessages; // Refresh UI only after some amount of items added
end;
@@ -991,7 +990,6 @@ begin
DebugMsg(['Found plugin ''', Plugin.ModuleID, ''', trying to open the archive ''', FileName, '''']);
xEngine := TVFSEngine.Create(Plugin);
xEngine.ParentEngine := FEngine;
- xEngine.ArchiveMode := True;
xEngine.SavePath := StartDir + FileName;
FEngine := xEngine;
VFSOpenResult := (FEngine as TVFSEngine).VFSOpenEx(IncludeTrailingPathDelimiter(StartDir) + FileName, nil, nil, nil, nil);
diff --git a/UTestPlugin.pas b/UTestPlugin.pas
index 9f8b369..2d92ae2 100644
--- a/UTestPlugin.pas
+++ b/UTestPlugin.pas
@@ -153,7 +153,7 @@ begin
for i := 0 to PluginList.Count - 1 do begin
MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
PluginOptionMenu.Items.Add(MenuItem);
end;
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;
diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas
index 01a31d3..5da4bc9 100644
--- a/vfs/uVFSprototypes.pas
+++ b/vfs/uVFSprototypes.pas
@@ -184,7 +184,7 @@ type
user_data: Pointer): LongBool; cdecl;
type
- // Log function which could plugin call - the application must handle the messages (e.g. write them to the stdout)
+ // Log function for plugin debugging output - host application will print or save these messages
PVFSLogFunc = ^TVFSLogFunc;
TVFSLogFunc = procedure(const S: PChar); cdecl;
@@ -193,16 +193,10 @@ type
TVFSFree = procedure (g: TVFSGlobs); cdecl;
// Performs cleanup and destroy all objects
TVFSVersion = function: integer; cdecl;
- // Returns API Version; the host application checks for this number and if the returned number is less than a value required by the host application, the module is not loaded
- // Please use the cVFSVersion constant as return value
+ // Returns VFS API Version; must match version hardcoded in the host program, otherwise the module is not loaded
+ // Please use the cVFSVersion constant as a return value
TVFSGetInfo = function: PVFSInfo; cdecl;
// Returns module info struct, tuxcmd will take care of memory deallocation
- TVFSGetPrefix = function (g:TVFSGlobs): PChar; cdecl;
- // Returns prefix used in the application to show difference between local and VFS filesystems (e.g. "ftp" or "smb")
- // tuxcmd will take care of memory deallocation
- TVFSGetCharset = function (g:TVFSGlobs): PChar; cdecl;
- // TODO: Returns charset which the plugin uses
- // tuxcmd will take care of memory deallocation
TVFSGetArchiveExts = function: PChar; cdecl;
// Returns the list of filename extensions which the module can handle separated by ';' (without a leading dots)
// Returning NULL or not defining the symbol at all means plugin can't handle archives
@@ -217,9 +211,11 @@ type
// Sets the block size for I/O operations (not all modules supports this)
- TVFSOpen = function (g:TVFSGlobs; const sName: PChar): TVFSResult; cdecl;
- // TODO: Opens the location (file or URI/URL)
- // In case of URI, do not supply password encoded in the string; plugin will automatically spawn the TVFSAskPasswordCallback callback
+ TVFSOpenArchive = function (g:TVFSGlobs; const sName: PChar): TVFSResult; cdecl;
+ // Opens specified archive. This will also switch plugin (an instance) into archiving mode
+ TVFSOpenURI = function (g:TVFSGlobs; const sURI: PChar): TVFSResult; cdecl;
+ // Opens specified network location. This will also switch plugin (an instance) into networking mode
+ // In case of URI, do not supply password encoded in the string; plugin will automatically spawn the TVFSAskPasswordCallback callback when needed
TVFSClose = function (g:TVFSGlobs): TVFSResult; cdecl;
// Closes the file or connection to the server
TVFSMkDir = function (g:TVFSGlobs; const sDirName: PChar): TVFSResult; cdecl;