summaryrefslogtreecommitdiff
path: root/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'vfs')
-rw-r--r--vfs/UVFSCore.pas280
-rw-r--r--vfs/uVFSprototypes.pas6
2 files changed, 139 insertions, 147 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas
index 5bf185e..b6c516d 100644
--- a/vfs/UVFSCore.pas
+++ b/vfs/UVFSCore.pas
@@ -21,7 +21,7 @@ unit UVFSCore;
interface
-uses GTKForms, ULibc, glib2, Classes, uVFSprototypes, UEngines, UCoreUtils;
+uses GTKForms, ULibc, lazglib2, Classes, uVFSprototypes, UEngines, UCoreUtils;
type
@@ -149,7 +149,7 @@ type
// VFS additions
function VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
- function VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
+ function VFSOpenEx(const AFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
function VFSClose(Error: PPGError): boolean;
function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
@@ -208,61 +208,61 @@ begin
ModuleHandle := PluginHandle;
// Find the symbols
- @FVFSNew := dlsym(ModuleHandle, 'VFSNew');
- @FVFSFree := dlsym(ModuleHandle, 'VFSFree');
- @FVFSVersion := dlsym(ModuleHandle, 'VFSVersion');
- @FVFSGetInfo := dlsym(ModuleHandle, 'VFSGetInfo');
- @FVFSOpenArchive := dlsym(ModuleHandle, 'VFSOpenArchive');
- @FVFSOpenURI := dlsym(ModuleHandle, 'VFSOpenURI');
- @FVFSClose := dlsym(ModuleHandle, 'VFSClose');
- @FVFSListFirst := dlsym(ModuleHandle, 'VFSListFirst');
- @FVFSListNext := dlsym(ModuleHandle, 'VFSListNext');
- @FVFSListClose := dlsym(ModuleHandle, 'VFSListClose');
- @FVFSGetPath := dlsym(ModuleHandle, 'VFSGetPath');
- @FVFSGetPathURI := dlsym(ModuleHandle, 'VFSGetPathURI');
- @FVFSChangeDir := dlsym(ModuleHandle, 'VFSChangeDir');
- @FVFSGetFileSystemInfo := dlsym(ModuleHandle, 'VFSGetFileSystemInfo');
- @FVFSFileInfo := dlsym(ModuleHandle, 'VFSFileInfo');
- @FVFSMkDir := dlsym(ModuleHandle, 'VFSMkDir');
- @FVFSRemove := dlsym(ModuleHandle, 'VFSRemove');
- @FVFSRename := dlsym(ModuleHandle, 'VFSRename');
- @FVFSMakeSymLink := dlsym(ModuleHandle, 'VFSMakeSymLink');
- @FVFSChmod := dlsym(ModuleHandle, 'VFSChmod');
- @FVFSChown := dlsym(ModuleHandle, 'VFSChown');
- @FVFSChangeTimes := dlsym(ModuleHandle, 'VFSChangeTimes');
- @FVFSGetDirSize := dlsym(ModuleHandle, 'VFSGetDirSize');
- @FVFSBreakGetDirSize := dlsym(ModuleHandle, 'VFSBreakGetDirSize');
- @FVFSCopyToLocal := dlsym(ModuleHandle, 'VFSCopyToLocal');
- @FVFSCopyFromLocal := dlsym(ModuleHandle, 'VFSCopyFromLocal');
- @FVFSOpenFile := dlsym(ModuleHandle, 'VFSOpenFile');
- @FVFSReadFile := dlsym(ModuleHandle, 'VFSReadFile');
- @FVFSWriteFile := dlsym(ModuleHandle, 'VFSWriteFile');
- @FVFSCloseFile := dlsym(ModuleHandle, 'VFSCloseFile');
- @FVFSFileSeek := dlsym(ModuleHandle, 'VFSFileSeek');
- @FVFSSetBlockSize := dlsym(ModuleHandle, 'VFSSetBlockSize');
- @FVFSIsOnSameFS := dlsym(ModuleHandle, 'VFSIsOnSameFS');
- @FVFSTwoSameFiles := dlsym(ModuleHandle, 'VFSTwoSameFiles');
- @FVFSGetArchiveExts := dlsym(ModuleHandle, 'VFSGetArchiveExts');
- @FVFSGetNetworkServices := dlsym(ModuleHandle, 'VFSGetNetworkServices');
- @FVFSGetPasswordRequired := dlsym(ModuleHandle, 'VFSGetPasswordRequired');
- @FVFSSetCallbacks := dlsym(ModuleHandle, 'VFSSetCallbacks');
- @FVFSResetPassword := dlsym(ModuleHandle, 'VFSResetPassword');
- @FVFSStartCopyOperation := dlsym(ModuleHandle, 'VFSStartCopyOperation');
- @FVFSStopCopyOperation := dlsym(ModuleHandle, 'VFSStopCopyOperation');
- @FVFSGetCapabilities := dlsym(ModuleHandle, 'VFSGetCapabilities');
+ FVFSNew := TVFSNew(dlsym(ModuleHandle, 'VFSNew'));
+ FVFSFree := TVFSFree(dlsym(ModuleHandle, 'VFSFree'));
+ FVFSVersion := TVFSVersion(dlsym(ModuleHandle, 'VFSVersion'));
+ FVFSGetInfo := TVFSGetInfo(dlsym(ModuleHandle, 'VFSGetInfo'));
+ FVFSOpenArchive := TVFSOpenArchive(dlsym(ModuleHandle, 'VFSOpenArchive'));
+ FVFSOpenURI := TVFSOpenURI(dlsym(ModuleHandle, 'VFSOpenURI'));
+ FVFSClose := TVFSClose(dlsym(ModuleHandle, 'VFSClose'));
+ FVFSListFirst := TVFSListFirst(dlsym(ModuleHandle, 'VFSListFirst'));
+ FVFSListNext := TVFSListNext(dlsym(ModuleHandle, 'VFSListNext'));
+ FVFSListClose := TVFSListClose(dlsym(ModuleHandle, 'VFSListClose'));
+ FVFSGetPath := TVFSGetPath(dlsym(ModuleHandle, 'VFSGetPath'));
+ FVFSGetPathURI := TVFSGetPathURI(dlsym(ModuleHandle, 'VFSGetPathURI'));
+ FVFSChangeDir := TVFSChangeDir(dlsym(ModuleHandle, 'VFSChangeDir'));
+ FVFSGetFileSystemInfo := TVFSGetFileSystemInfo(dlsym(ModuleHandle, 'VFSGetFileSystemInfo'));
+ FVFSFileInfo := TVFSFileInfo(dlsym(ModuleHandle, 'VFSFileInfo'));
+ FVFSMkDir := TVFSMkDir(dlsym(ModuleHandle, 'VFSMkDir'));
+ FVFSRemove := TVFSRemove(dlsym(ModuleHandle, 'VFSRemove'));
+ FVFSRename := TVFSRename(dlsym(ModuleHandle, 'VFSRename'));
+ FVFSMakeSymLink := TVFSMakeSymLink(dlsym(ModuleHandle, 'VFSMakeSymLink'));
+ FVFSChmod := TVFSChmod(dlsym(ModuleHandle, 'VFSChmod'));
+ FVFSChown := TVFSChown(dlsym(ModuleHandle, 'VFSChown'));
+ FVFSChangeTimes := TVFSChangeTimes(dlsym(ModuleHandle, 'VFSChangeTimes'));
+ FVFSGetDirSize := TVFSGetDirSize(dlsym(ModuleHandle, 'VFSGetDirSize'));
+ FVFSBreakGetDirSize := TVFSBreakGetDirSize(dlsym(ModuleHandle, 'VFSBreakGetDirSize'));
+ FVFSCopyToLocal := TVFSCopyToLocal(dlsym(ModuleHandle, 'VFSCopyToLocal'));
+ FVFSCopyFromLocal := TVFSCopyFromLocal(dlsym(ModuleHandle, 'VFSCopyFromLocal'));
+ FVFSOpenFile := TVFSOpenFile(dlsym(ModuleHandle, 'VFSOpenFile'));
+ FVFSReadFile := TVFSReadFile(dlsym(ModuleHandle, 'VFSReadFile'));
+ FVFSWriteFile := TVFSWriteFile(dlsym(ModuleHandle, 'VFSWriteFile'));
+ FVFSCloseFile := TVFSCloseFile(dlsym(ModuleHandle, 'VFSCloseFile'));
+ FVFSFileSeek := TVFSFileSeek(dlsym(ModuleHandle, 'VFSFileSeek'));
+ FVFSSetBlockSize := TVFSSetBlockSize(dlsym(ModuleHandle, 'VFSSetBlockSize'));
+ FVFSIsOnSameFS := TVFSIsOnSameFS(dlsym(ModuleHandle, 'VFSIsOnSameFS'));
+ FVFSTwoSameFiles := TVFSTwoSameFiles(dlsym(ModuleHandle, 'VFSTwoSameFiles'));
+ FVFSGetArchiveExts := TVFSGetArchiveExts(dlsym(ModuleHandle, 'VFSGetArchiveExts'));
+ FVFSGetNetworkServices := TVFSGetNetworkServices(dlsym(ModuleHandle, 'VFSGetNetworkServices'));
+ FVFSGetPasswordRequired := TVFSGetPasswordRequired(dlsym(ModuleHandle, 'VFSGetPasswordRequired'));
+ FVFSSetCallbacks := TVFSSetCallbacks(dlsym(ModuleHandle, 'VFSSetCallbacks'));
+ FVFSResetPassword := TVFSResetPassword(dlsym(ModuleHandle, 'VFSResetPassword'));
+ FVFSStartCopyOperation := TVFSStartCopyOperation(dlsym(ModuleHandle, 'VFSStartCopyOperation'));
+ FVFSStopCopyOperation := TVFSStopCopyOperation(dlsym(ModuleHandle, 'VFSStopCopyOperation'));
+ FVFSGetCapabilities := TVFSGetCapabilities(dlsym(ModuleHandle, 'VFSGetCapabilities'));
// Initialize the extensions list
SetLength(Extensions, 0);
SetLength(Services, 0);
- if (@FVFSGetArchiveExts <> nil) and (@FVFSOpenArchive <> nil) then begin
- s := FVFSGetArchiveExts;
+ 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) and (@FVFSOpenURI <> nil) then begin
- s := FVFSGetNetworkServices;
+ if (FVFSGetNetworkServices <> nil) and (FVFSOpenURI <> nil) then begin
+ s := FVFSGetNetworkServices();
if s <> nil then begin
ParseString(String(s), ';', Services);
real_libc_free(s);
@@ -281,8 +281,8 @@ end;
(********************************************************************************************************************************)
function TVFSPlugin.VFSVersion: integer;
begin
- if @FVFSVersion <> nil then Result := FVFSVersion
- else Result := -1;
+ if FVFSVersion <> nil then Result := FVFSVersion()
+ else Result := -1;
end;
procedure _free_PVFSInfo(Info: PVFSInfo);
@@ -298,9 +298,9 @@ end;
function TVFSPlugin.ModuleID: string;
var Info: PVFSInfo;
begin
- if @FVFSGetInfo <> nil then begin
- Info := FVFSGetInfo;
- Result := String(Info.ID);
+ if FVFSGetInfo <> nil then begin
+ Info := FVFSGetInfo();
+ Result := String(Info^.ID);
_free_PVFSInfo(Info);
end else Result := '';
end;
@@ -308,9 +308,9 @@ end;
function TVFSPlugin.ModuleName: string;
var Info: PVFSInfo;
begin
- if @FVFSGetInfo <> nil then begin
- Info := FVFSGetInfo;
- Result := String(Info.Name);
+ if FVFSGetInfo <> nil then begin
+ Info := FVFSGetInfo();
+ Result := String(Info^.Name);
_free_PVFSInfo(Info);
end else Result := '';
end;
@@ -318,9 +318,9 @@ end;
function TVFSPlugin.ModuleAbout: string;
var Info: PVFSInfo;
begin
- if @FVFSGetInfo <> nil then begin
- Info := FVFSGetInfo;
- Result := String(Info.About);
+ if FVFSGetInfo <> nil then begin
+ Info := FVFSGetInfo();
+ Result := String(Info^.About);
_free_PVFSInfo(Info);
end else Result := '';
end;
@@ -328,21 +328,21 @@ end;
function TVFSPlugin.ModuleCopyright: string;
var Info: PVFSInfo;
begin
- if @FVFSGetInfo <> nil then begin
- Info := FVFSGetInfo;
- Result := String(Info.Copyright);
+ if FVFSGetInfo <> nil then begin
+ Info := FVFSGetInfo();
+ Result := String(Info^.Copyright);
_free_PVFSInfo(Info);
end else Result := '';
end;
function TVFSPlugin.GetHandlesArchives: boolean;
begin
- Result := (Length(Extensions) > 0) and (@FVFSOpenArchive <> nil);
+ Result := (Length(Extensions) > 0) and (FVFSOpenArchive <> nil);
end;
function TVFSPlugin.GetHandlesNetwork: boolean;
begin
- Result := (Length(Services) > 0) and (@FVFSOpenURI <> nil);
+ Result := (Length(Services) > 0) and (FVFSOpenURI <> nil);
end;
(********************************************************************************************************************************)
@@ -364,13 +364,13 @@ begin
FCopyProgressCallback := nil;
FCopyCallbackData := nil;
- if @FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(@VFSLogFunc);
+ if FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(PVFSLogFunc(@VFSLogFunc));
end;
destructor TVFSEngine.Destroy;
begin
try
- if @FSourcePlugin.FVFSFree <> nil then FSourcePlugin.FVFSFree(FGlobs);
+ if FSourcePlugin.FVFSFree <> nil then FSourcePlugin.FVFSFree(FGlobs);
if Length(Trim(RemoveFileOnClose)) > 0 then
if unlink(PChar(RemoveFileOnClose)) <> 0 then
DebugMsg(['(EE) TVFSEngine.Destroy: error while removing ''', RemoveFileOnClose, ''': ', strerror(errno)]);
@@ -383,13 +383,13 @@ function TVFSEngine.VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQu
begin
Result := False;
try
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenURI <> nil) then begin
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSOpenURI <> nil) then begin
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
Result := FSourcePlugin.FVFSOpenURI(FGlobs, PChar(URI), Error);
FArchiveMode := False;
FArchivePath := '';
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
end;
except
@@ -400,18 +400,18 @@ begin
end;
end;
-function TVFSEngine.VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
+function TVFSEngine.VFSOpenEx(const AFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
begin
Result := False;
try
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenArchive <> nil) then begin
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSOpenArchive <> nil) then begin
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
- Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(OpenFile), Error);
+ Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(AFile), Error);
FArchiveMode := True;
- if Result then FArchivePath := OpenFile
+ if Result then FArchivePath := AFile
else FArchivePath := '';
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
end;
except
@@ -426,7 +426,7 @@ end;
function TVFSEngine.VFSClose(Error: PPGError): boolean;
begin
Result := False;
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSClose <> nil) then
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSClose <> nil) then
Result := FSourcePlugin.FVFSClose(FGlobs, Error);
end;
@@ -469,8 +469,8 @@ begin
DebugMsg(['^^VFS (II): GetListing begin']);
Result := False;
try
- if (@FSourcePlugin.FVFSListFirst = nil) or (@FSourcePlugin.FVFSListNext = nil) or (@FSourcePlugin.FVFSListClose = nil) then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'File listing not supported by the VFS module.');
+ if (FSourcePlugin.FVFSListFirst = nil) or (FSourcePlugin.FVFSListNext = nil) or (FSourcePlugin.FVFSListClose = nil) then begin
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'File listing not supported by the VFS module.');
Exit;
end;
P := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), FollowSymlinks, AddFullPath, Error);
@@ -493,7 +493,7 @@ begin
if Error^ <> nil then
g_error_free(Error^);
Error^ := nil;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED), '%s', 'The operation has been cancelled.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED), 'The operation has been cancelled.');
Result := False;
end;
real_libc_free(P);
@@ -515,8 +515,8 @@ begin
DebugMsg(['^^VFS (II): GetFileInfo begin']);
Result := nil;
- if @FSourcePlugin.FVFSFileInfo = nil then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Querying file info is not supported by the VFS module.');
+ if FSourcePlugin.FVFSFileInfo = nil then begin
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Querying file info is not supported by the VFS module.');
Exit;
end;
try
@@ -547,7 +547,7 @@ begin
FSSize := -1;
FSFree := -1;
FSName := 'plugin';
- if @FSourcePlugin.FVFSGetFileSystemInfo <> nil then begin
+ if FSourcePlugin.FVFSGetFileSystemInfo <> nil then begin
AFSSize := -1;
AFSFree := -1;
AFSName := nil;
@@ -578,7 +578,7 @@ function TVFSEngine.GetPath: string;
var s: PChar;
begin
Result := '/';
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetPath <> nil) then begin
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSGetPath <> nil) then begin
s := FSourcePlugin.FVFSGetPath(FGlobs);
if s <> nil then begin
Result := String(s);
@@ -591,7 +591,7 @@ function TVFSEngine.GetPathURI: string;
var s: PChar;
begin
Result := '';
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetPathURI <> nil) then begin
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSGetPathURI <> nil) then begin
s := FSourcePlugin.FVFSGetPathURI(FGlobs);
if s <> nil then begin
Result := String(s);
@@ -619,12 +619,12 @@ function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFS
begin
Result := False;
try
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSChangeDir <> nil) then begin
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSChangeDir <> nil) then begin
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
Result := ChangeDir(NewPath, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_CHDIR);
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
end;
except
@@ -645,7 +645,7 @@ function TVFSEngine.FileExists(const FileName: string; FollowSymlinks: boolean):
var P: PVFSItem;
begin
Result := False;
- if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then
+ if (FGlobs = nil) or (FSourcePlugin.FVFSFileInfo = nil) then
Exit;
try
P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil);
@@ -661,7 +661,7 @@ function TVFSEngine.DirectoryExists(const FileName: string; FollowSymlinks: bool
var P: PVFSItem;
begin
Result := False;
- if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then
+ if (FGlobs = nil) or (FSourcePlugin.FVFSFileInfo = nil) then
Exit;
try
P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil);
@@ -675,91 +675,91 @@ end;
function TVFSEngine.MakeDir(const NewDir: string; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSMkDir <> nil then begin
+ if FSourcePlugin.FVFSMkDir <> nil then begin
Result := FSourcePlugin.FVFSMkDir(FGlobs, PChar(NewDir), Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_MKDIR);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Creating directories is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Creating directories is not supported by the VFS module.');
end;
end;
function TVFSEngine.Remove(const APath: string; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSRemove <> nil then begin
+ if FSourcePlugin.FVFSRemove <> nil then begin
Result := FSourcePlugin.FVFSRemove(FGlobs, PChar(APath), Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_REMOVE);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Removing files is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Removing files is not supported by the VFS module.');
end;
end;
function TVFSEngine.RenameFile(const SourceFile, DestFile: string; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSRename <> nil then begin
+ if FSourcePlugin.FVFSRename <> nil then begin
Result := FSourcePlugin.FVFSRename(FGlobs, PChar(SourceFile), PChar(DestFile), Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_RENAME);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Renaming files is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Renaming files is not supported by the VFS module.');
end;
end;
function TVFSEngine.MakeSymLink(const NewFileName, PointTo: string; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSMakeSymLink <> nil then begin
+ if FSourcePlugin.FVFSMakeSymLink <> nil then begin
Result := FSourcePlugin.FVFSMakeSymLink(FGlobs, PChar(NewFileName), PChar(PointTo), Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_SYMLINK);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Creating symbolic links is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Creating symbolic links is not supported by the VFS module.');
end;
end;
function TVFSEngine.Chmod(const FileName: string; Mode: cuLong; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSChmod <> nil then begin
+ if FSourcePlugin.FVFSChmod <> nil then begin
Result := FSourcePlugin.FVFSChmod(FGlobs, PChar(FileName), Mode, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_CHMOD);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Chmod is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Chmod is not supported by the VFS module.');
end;
end;
function TVFSEngine.Chown(const FileName: string; UID, GID: cuLong; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSChown <> nil then begin
+ if FSourcePlugin.FVFSChown <> nil then begin
Result := FSourcePlugin.FVFSChown(FGlobs, PChar(FileName), UID, GID, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_CHOWN);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Chown is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Chown is not supported by the VFS module.');
end;
end;
function TVFSEngine.ChangeTimes(const APath: string; mtime, atime: time_t; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSChangeTimes <> nil then begin
+ if FSourcePlugin.FVFSChangeTimes <> nil then begin
Result := FSourcePlugin.FVFSChangeTimes(FGlobs, PChar(APath), mtime, atime, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_TIMESTAMPS);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Changing timestamps is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Changing timestamps is not supported by the VFS module.');
end;
end;
function TVFSEngine.GetDirSize(const APath: string): Int64;
begin
- if @FSourcePlugin.FVFSGetDirSize <> nil then Result := FSourcePlugin.FVFSGetDirSize(FGlobs, PChar(APath))
+ if FSourcePlugin.FVFSGetDirSize <> nil then Result := FSourcePlugin.FVFSGetDirSize(FGlobs, PChar(APath))
else Result := 0;
end;
procedure TVFSEngine.BreakProcessing(ProcessingKind: integer);
begin
case ProcessingKind of
- 1: if @FSourcePlugin.FVFSBreakGetDirSize <> nil then FSourcePlugin.FVFSBreakGetDirSize(FGlobs);
+ 1: if FSourcePlugin.FVFSBreakGetDirSize <> nil then FSourcePlugin.FVFSBreakGetDirSize(FGlobs);
end;
end;
@@ -770,7 +770,7 @@ end;
procedure TVFSEngine.SetBlockSize(Value: Cardinal);
begin
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSSetBlockSize <> nil)
+ if (FGlobs <> nil) and (FSourcePlugin.FVFSSetBlockSize <> nil)
then FSourcePlugin.FVFSSetBlockSize(FGlobs, Value);
end;
@@ -779,69 +779,69 @@ end;
(********************************************************************************************************************************)
function TVFSEngine.IsOnSameFS(const Path1, Path2: string; FollowSymlinks: boolean): boolean;
begin
- if @FSourcePlugin.FVFSIsOnSameFS <> nil
+ if FSourcePlugin.FVFSIsOnSameFS <> nil
then Result := FSourcePlugin.FVFSIsOnSameFS(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks)
else Result := True;
end;
function TVFSEngine.OpenFile(const APath: string; Mode: integer; Error: PPGError): TEngineFileDes;
begin
- if @FSourcePlugin.FVFSOpenFile <> nil then begin
+ if FSourcePlugin.FVFSOpenFile <> nil then begin
Result := FSourcePlugin.FVFSOpenFile(FGlobs, PChar(APath), Mode, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_OPEN_FILE);
end else begin
Result := nil;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual opening files is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual opening files is not supported by the VFS module.');
end;
end;
function TVFSEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; Error: PPGError): integer;
begin
- if @FSourcePlugin.FVFSReadFile <> nil then begin
+ if FSourcePlugin.FVFSReadFile <> nil then begin
Result := FSourcePlugin.FVFSReadFile(FGlobs, FileDescriptor, Buffer, ABlockSize, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_READ_FILE);
end else begin
Result := -1;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual read is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual read is not supported by the VFS module.');
end;
end;
function TVFSEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; Error: PPGError): integer;
begin
- if @FSourcePlugin.FVFSWriteFile <> nil then begin
+ if FSourcePlugin.FVFSWriteFile <> nil then begin
Result := FSourcePlugin.FVFSWriteFile(FGlobs, FileDescriptor, Buffer, BytesCount, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_WRITE_FILE);
end else begin
Result := -1;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual write is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual write is not supported by the VFS module.');
end;
end;
function TVFSEngine.CloseFile(const FileDescriptor: TEngineFileDes; Error: PPGError): boolean;
begin
- if @FSourcePlugin.FVFSCloseFile <> nil then begin
+ if FSourcePlugin.FVFSCloseFile <> nil then begin
Result := FSourcePlugin.FVFSCloseFile(FGlobs, FileDescriptor, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_CLOSE_FILE);
end else begin
Result := False;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual closing files is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual closing files is not supported by the VFS module.');
end;
end;
function TVFSEngine.FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; Error: PPGError): Int64;
begin
- if @FSourcePlugin.FVFSFileSeek <> nil then begin
+ if FSourcePlugin.FVFSFileSeek <> nil then begin
Result := FSourcePlugin.FVFSFileSeek(FGlobs, FileDescriptor, AbsoluteOffset, Error);
VFSToTuxcmdError(Error, TUXCMD_ERROR_SEEK);
end else begin
Result := -1;
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual seek is not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual seek is not supported by the VFS module.');
end;
end;
function TVFSEngine.TwoSameFiles(const Path1, Path2: string; FollowSymlinks: boolean): boolean;
begin
- if @FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks)
+ if FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks)
else Result := False;
end;
@@ -865,23 +865,20 @@ begin
end;
function TVFSEngine.CopyFileOutEx(const SourceFile, DestFile: string; Append: boolean; Error: PPGError): boolean;
-var ACopyProgressCallback: TVFSProgressCallback;
begin
Result := False;
try
- if @FSourcePlugin.FVFSCopyToLocal <> nil then
+ if FSourcePlugin.FVFSCopyToLocal <> nil then
try
Result := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, Error)
except
on E: Exception do tuxcmd_set_error_from_exception(Error, E);
end
else
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyToLocal not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSCopyToLocal not supported by the VFS module.');
if Error^ <> nil then begin
- if FCopyProgressCallback <> nil then begin
- @ACopyProgressCallback := FCopyProgressCallback;
- Result := ACopyProgressCallback(0, Error^, FCopyCallbackData);
- end;
+ if FCopyProgressCallback <> nil then
+ Result := TVFSProgressCallback(FCopyProgressCallback)(0, Error^, FCopyCallbackData);
end;
except
on E: Exception do begin
@@ -893,23 +890,20 @@ begin
end;
function TVFSEngine.CopyFileInEx(const SourceFile, DestFile: string; Append: boolean; Error: PPGError): boolean;
-var ACopyProgressCallback: TVFSProgressCallback;
begin
Result := False;
try
- if @FSourcePlugin.FVFSCopyFromLocal <> nil then
+ if FSourcePlugin.FVFSCopyFromLocal <> nil then
try
Result := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, Error)
except
on E: Exception do tuxcmd_set_error_from_exception(Error, E);
end
else
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyFromLocal not supported by the VFS module.');
+ g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSCopyFromLocal not supported by the VFS module.');
if Error <> nil then begin
- if FCopyProgressCallback <> nil then begin
- @ACopyProgressCallback := FCopyProgressCallback;
- Result := ACopyProgressCallback(0, Error^, FCopyCallbackData);
- end;
+ if FCopyProgressCallback <> nil then
+ Result := TVFSProgressCallback(FCopyProgressCallback)(0, Error^, FCopyCallbackData);
end;
except
on E: Exception do begin
@@ -925,20 +919,20 @@ var Error: PGError;
begin
Result := not ArchiveMode;
try
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
FCopyProgressCallback := ProgressCallback;
FCopyCallbackData := CallbackData;
if ArchiveMode then begin
Error := nil;
- if @FSourcePlugin.FVFSStartCopyOperation <> nil then
+ if FSourcePlugin.FVFSStartCopyOperation <> nil then
try
Result := FSourcePlugin.FVFSStartCopyOperation(FGlobs, @Error)
except
on E: Exception do tuxcmd_set_error_from_exception(@Error, E);
end
else
- g_set_error(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSStartCopyOperation not supported by the VFS module.');
+ g_set_error_literal(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSStartCopyOperation not supported by the VFS module.');
if Error <> nil then begin
if ProgressCallback <> nil then
Result := ProgressCallback^(0, Error, CallbackData);
@@ -955,18 +949,18 @@ var Error: PGError;
begin
Result := not ArchiveMode;
try
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ if FSourcePlugin.FVFSSetCallbacks <> nil then
FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
if ArchiveMode then begin
Error := nil;
- if @FSourcePlugin.FVFSStopCopyOperation <> nil then
+ if FSourcePlugin.FVFSStopCopyOperation <> nil then
try
Result := FSourcePlugin.FVFSStopCopyOperation(FGlobs, @Error)
except
on E: Exception do tuxcmd_set_error_from_exception(@Error, E);
end
else
- g_set_error(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSStopCopyOperation not supported by the VFS module.');
+ g_set_error_literal(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSStopCopyOperation not supported by the VFS module.');
if Error <> nil then begin
if ProgressCallback <> nil then
Result := ProgressCallback^(0, Error, CallbackData);
@@ -985,13 +979,13 @@ end;
(********************************************************************************************************************************)
function TVFSEngine.GetPasswordRequired: boolean;
begin
- if @FSourcePlugin.FVFSGetPasswordRequired <> nil then Result := FSourcePlugin.FVFSGetPasswordRequired(FGlobs)
+ if FSourcePlugin.FVFSGetPasswordRequired <> nil then Result := FSourcePlugin.FVFSGetPasswordRequired(FGlobs)
else Result := False;
end;
procedure TVFSEngine.ResetPassword;
begin
- if @FSourcePlugin.FVFSResetPassword <> nil then
+ if FSourcePlugin.FVFSResetPassword <> nil then
FSourcePlugin.FVFSResetPassword(FGlobs);
end;
@@ -1006,7 +1000,7 @@ end;
function TVFSEngine.GetArchiveStreamingType: boolean;
begin
Result := False;
- if (@FSourcePlugin.FVFSGetCapabilities <> nil) then
+ if (FSourcePlugin.FVFSGetCapabilities <> nil) then
Result := (FSourcePlugin.FVFSGetCapabilities() and VFS_CAP_ARCHIVE_STREAMING) = VFS_CAP_ARCHIVE_STREAMING;
end;
@@ -1101,8 +1095,8 @@ begin
ModuleHandler := dlopen(PChar(IncludeTrailingPathDelimiter(s) + Buf), RTLD_NOW);
if ModuleHandler = nil then DebugMsg([' XXX Error loading module: ', dlerror])
else try
- @VFSVersionFunc := dlsym(ModuleHandler, 'VFSVersion');
- if (@VFSVersionFunc <> nil) and (VFSVersionFunc = ConstVFSVersionRequired) then begin
+ VFSVersionFunc := TVFSVersion(dlsym(ModuleHandler, 'VFSVersion'));
+ if (VFSVersionFunc <> nil) and (VFSVersionFunc() = ConstVFSVersionRequired) then begin
PluginItem := TVFSPlugin.Create(ModuleHandler);
PluginItem.FullModulePath := IncludeTrailingPathDelimiter(s) + Buf;
PluginList.Add(PluginItem);
diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas
index 6fbe65d..3a4b205 100644
--- a/vfs/uVFSprototypes.pas
+++ b/vfs/uVFSprototypes.pas
@@ -27,11 +27,9 @@ unit uVFSprototypes;
interface
-uses glib2;
+uses lazglib2;
-{$IFDEF FPC}
- {$PACKRECORDS C}
-{$ENDIF}
+{$PACKRECORDS C}
const
cVFSVersion = 5; // current version of the VFS API