summaryrefslogtreecommitdiff
path: root/vfs/UVFSCore.pas
diff options
context:
space:
mode:
Diffstat (limited to 'vfs/UVFSCore.pas')
-rw-r--r--vfs/UVFSCore.pas118
1 files changed, 80 insertions, 38 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas
index d875b83..0ce7e1f 100644
--- a/vfs/UVFSCore.pas
+++ b/vfs/UVFSCore.pas
@@ -382,29 +382,43 @@ end;
function TVFSEngine.VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
begin
Result := False;
- 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
- FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ try
+ 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
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ end;
+ except
+ on E: Exception do begin
+ g_set_error_from_exception(Error, E);
+ Result := False;
+ end;
end;
end;
function TVFSEngine.VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
begin
Result := False;
- 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);
- FArchiveMode := True;
- if Result then FArchivePath := OpenFile
- else FArchivePath := '';
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ try
+ 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);
+ FArchiveMode := True;
+ if Result then FArchivePath := OpenFile
+ else FArchivePath := '';
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ end;
+ except
+ on E: Exception do begin
+ g_set_error_from_exception(Error, E);
+ Result := False;
+ end;
end;
end;
@@ -487,8 +501,11 @@ begin
real_libc_free(P);
FSourcePlugin.FVFSListClose(FGlobs, nil);
except
- on E: Exception do
+ on E: Exception do begin
DebugMsg(['^^VFS (EE): GetListing: Exception: ', E.Message]);
+ g_set_error_from_exception(Error, E);
+ Result := False;
+ end;
end;
BreakProcessingType := 0;
DebugMsg(['^^VFS (II): GetListing end.']);
@@ -513,8 +530,11 @@ begin
if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo);
real_libc_free(P);
except
- on E: Exception do
+ on E: Exception do begin
DebugMsg(['^^VFS (EE): GetFileInfo: Exception: ', E.Message]);
+ g_set_error_from_exception(Error, E);
+ Result := nil;
+ end;
end;
DebugMsg(['^^VFS (II): GetFileInfo end.']);
end;
@@ -586,19 +606,31 @@ begin
try
Result := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(NewPath), Error);
except
- on E: Exception do DebugMsg(['^^VFS (EE): ChangeDir: Exception: ', E.Message]);
+ on E: Exception do begin
+ DebugMsg(['^^VFS (EE): ChangeDir: Exception: ', E.Message]);
+ g_set_error_from_exception(Error, E);
+ Result := False;
+ end;
end;
end;
function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean;
begin
Result := False;
- 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);
- if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ try
+ 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);
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ end;
+ except
+ on E: Exception do begin
+ DebugMsg(['^^VFS (EE): ChangeDirEx: Exception: ', E.Message]);
+ g_set_error_from_exception(Error, E);
+ Result := False;
+ end;
end;
end;
@@ -823,7 +855,11 @@ begin
try
Error := nil;
if @FSourcePlugin.FVFSCopyToLocal <> nil then
- Result := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error)
+ try
+ Result := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error)
+ except
+ on E: Exception do g_set_error_from_exception(@Error, E);
+ end
else
g_set_error(@Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyToLocal not supported by the VFS module.');
if Error <> nil then begin
@@ -834,10 +870,7 @@ begin
g_error_free(Error);
end;
except
- on E: Exception do begin
- DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOutEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]);
- Result := False;
- end;
+ on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOutEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]);
end;
end;
@@ -849,7 +882,11 @@ begin
try
Error := nil;
if @FSourcePlugin.FVFSCopyFromLocal <> nil then
- Result := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error)
+ try
+ Result := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error)
+ except
+ on E: Exception do g_set_error_from_exception(@Error, E);
+ end
else
g_set_error(@Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyFromLocal not supported by the VFS module.');
if Error <> nil then begin
@@ -860,10 +897,7 @@ begin
g_error_free(Error);
end;
except
- on E: Exception do begin
- DebugMsg(['*** Exception raised in TVFSEngine.CopyFileInEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]);
- Result := False;
- end;
+ on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.CopyFileInEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]);
end;
end;
@@ -879,7 +913,11 @@ begin
if ArchiveMode then begin
Error := nil;
if @FSourcePlugin.FVFSStartCopyOperation <> nil then
- Result := FSourcePlugin.FVFSStartCopyOperation(FGlobs, @Error)
+ try
+ Result := FSourcePlugin.FVFSStartCopyOperation(FGlobs, @Error)
+ except
+ on E: Exception do g_set_error_from_exception(@Error, E);
+ end
else
g_set_error(@Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'VFSStartCopyOperation not supported by the VFS module.');
if Error <> nil then begin
@@ -903,7 +941,11 @@ begin
if ArchiveMode then begin
Error := nil;
if @FSourcePlugin.FVFSStopCopyOperation <> nil then
- Result := FSourcePlugin.FVFSStopCopyOperation(FGlobs, @Error)
+ try
+ Result := FSourcePlugin.FVFSStopCopyOperation(FGlobs, @Error)
+ except
+ on E: Exception do g_set_error_from_exception(@Error, E);
+ end
else
g_set_error(@Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'VFSStopCopyOperation not supported by the VFS module.');
if Error <> nil then begin