diff options
Diffstat (limited to 'vfs')
| -rw-r--r-- | vfs/UVFSCore.pas | 469 | ||||
| -rw-r--r-- | vfs/uVFSprototypes.pas | 86 |
2 files changed, 281 insertions, 274 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index cf3e36a..d875b83 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -97,6 +97,8 @@ type FBlockSize: Cardinal; FArchiveMode: boolean; FArchivePath: string; + FCopyProgressCallback: PVFSProgressCallback; + FCopyCallbackData: Pointer; function GetPluginID: string; function GetDataItemFromVFSItem(P: PVFSItem): PDataItem; function GetArchiveStreamingType: boolean; @@ -109,10 +111,10 @@ type constructor Create(SourcePlugin: TVFSPlugin); destructor Destroy; override; - function GetListing(List: TList; const APath: string; AddDotFiles, FollowSymlinks, AddFullPath: boolean): integer; override; - function GetFileInfo(const APath: string; FollowSymlinks, AddFullPath: boolean): PDataItem; override; + function GetListing(List: TList; const APath: string; AddDotFiles, FollowSymlinks, AddFullPath: boolean; Error: PPGError): boolean; override; + function GetFileInfo(const APath: string; FollowSymlinks, AddFullPath: boolean; Error: PPGError): PDataItem; override; - function ChangeDir(const NewPath: string): integer; override; + function ChangeDir(const NewPath: string; Error: PPGError): boolean; override; function GetPath: string; override; procedure SetPath(Value: string); override; @@ -124,32 +126,32 @@ type function IsOnROMedium(const FileName: string): boolean; override; function FileCanRun(const FileName: string): boolean; override; - function MakeDir(const NewDir: string): integer; override; - function Remove(const APath: string): integer; override; - function MakeSymLink(const NewFileName, PointTo: string): integer; override; - function Chmod(const FileName: string; Mode: cuLong): integer; override; - function Chown(const FileName: string; UID, GID: cuLong): integer; override; - function RenameFile(const SourceFile, DestFile: string): integer; override; - function ChangeTimes(const APath: string; mtime, atime: time_t): integer; override; + function MakeDir(const NewDir: string; Error: PPGError): boolean; override; + function Remove(const APath: string; Error: PPGError): boolean; override; + function MakeSymLink(const NewFileName, PointTo: string; Error: PPGError): boolean; override; + function Chmod(const FileName: string; Mode: cuLong; Error: PPGError): boolean; override; + function Chown(const FileName: string; UID, GID: cuLong; Error: PPGError): boolean; override; + function RenameFile(const SourceFile, DestFile: string; Error: PPGError): boolean; override; + function ChangeTimes(const APath: string; mtime, atime: time_t; Error: PPGError): boolean; override; function GetBlockSize: guint32; override; procedure SetBlockSize(Value: guint32); override; - function CopyFileIn(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override; - function CopyFileOut(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override; + function CopyFileIn(const SourceFile, DestFile: string; Append: boolean; ProgressFunc: TEngineProgressFunc; Sender: Pointer): boolean; override; + function CopyFileOut(const SourceFile, DestFile: string; Append: boolean; ProgressFunc: TEngineProgressFunc; Sender: Pointer): boolean; override; function IsOnSameFS(const Path1, Path2: string; FollowSymlinks: boolean): boolean; override; function TwoSameFiles(const Path1, Path2: string; FollowSymlinks: boolean): boolean; override; - function OpenFile(const APath: string; Mode: integer; var Error: integer): TEngineFileDes; override; - function ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; var Error: integer): integer; override; - function WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; var Error: integer): integer; override; - function CloseFile(const FileDescriptor: TEngineFileDes): integer; override; - function FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; var Error: integer): Int64; override; + function OpenFile(const APath: string; Mode: integer; Error: PPGError): TEngineFileDes; override; + function ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; Error: PPGError): integer; override; + function WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; Error: PPGError): integer; override; + function CloseFile(const FileDescriptor: TEngineFileDes; Error: PPGError): boolean; override; + function FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; Error: PPGError): Int64; override; // VFS additions - function VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; - function VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult; - function VFSClose: boolean; - function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): integer; + 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 VFSClose(Error: PPGError): boolean; + function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; function GetPathURI: string; @@ -157,10 +159,10 @@ type procedure ResetPassword; // callbacks here are used for next volume prompts, password prompts (encrypted archives) - function StartCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; - function StopCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc): boolean; - function CopyFileInEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; - function CopyFileOutEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; + function StartCopyOperation(AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; + function StopCopyOperation(ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; + function CopyFileOutEx(const SourceFile, DestFile: string; Append: boolean): boolean; + function CopyFileInEx(const SourceFile, DestFile: string; Append: boolean): boolean; published property PluginID: string read GetPluginID; property ArchiveMode: boolean read FArchiveMode; @@ -176,7 +178,7 @@ var PluginList: TList; implementation -uses SysUtils, UConfig, ULocale; +uses SysUtils, UConfig, ULocale, UError; const ConstGlobalModulePath1 = '/usr/lib/tuxcmd'; @@ -359,6 +361,8 @@ begin RemoveFileOnClose := ''; OpenedFromQuickConnect := False; CustomPluginIDSave := ''; + FCopyProgressCallback := nil; + FCopyCallbackData := nil; if @FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(@VFSLogFunc); end; @@ -375,13 +379,13 @@ begin end; end; -function TVFSEngine.VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; +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)) = cVFS_OK; + Result := FSourcePlugin.FVFSOpenURI(FGlobs, PChar(URI), Error); FArchiveMode := False; FArchivePath := ''; if @FSourcePlugin.FVFSSetCallbacks <> nil then @@ -389,27 +393,27 @@ begin end; end; -function TVFSEngine.VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult; +function TVFSEngine.VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; begin - Result := cVFS_OK; + 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)); + Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(OpenFile), Error); FArchiveMode := True; - if Result = cVFS_OK then FArchivePath := OpenFile - else FArchivePath := ''; + if Result then FArchivePath := OpenFile + else FArchivePath := ''; if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; end; (********************************************************************************************************************************) -function TVFSEngine.VFSClose: boolean; +function TVFSEngine.VFSClose(Error: PPGError): boolean; begin Result := False; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSClose <> nil) - then Result := FSourcePlugin.FVFSClose(FGlobs) = cVFS_OK; + if (FGlobs <> nil) and (@FSourcePlugin.FVFSClose <> nil) then + Result := FSourcePlugin.FVFSClose(FGlobs, Error); end; function TVFSEngine.GetDataItemFromVFSItem(P: PVFSItem): PDataItem; @@ -444,30 +448,21 @@ begin Result := Item; end; -function TVFSEngine.GetListing(List: TList; const APath: string; AddDotFiles, FollowSymlinks, AddFullPath: boolean): integer; +function TVFSEngine.GetListing(List: TList; const APath: string; AddDotFiles, FollowSymlinks, AddFullPath: boolean; Error: PPGError): boolean; var P: PVFSItem; Item: PDataItem; - Res: integer; + FError: PGError; begin DebugMsg(['^^VFS (II): GetListing begin']); - Result := 0; + Result := False; try - if @FSourcePlugin.FVFSListFirst = nil then begin - Result := ERRNoAccess; - Exit; - end; - P := real_libc_malloc(sizeof(TVFSItem)); - memset(P, 0, sizeof(TVFSItem)); - Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P, FollowSymlinks, AddFullPath); - if Res <> cVFS_OK then begin - FSourcePlugin.FVFSListClose(FGlobs); - if Res = cVFS_Not_More_Files then Result := 0 - else Result := Res; - real_libc_free(P); + if (@FSourcePlugin.FVFSListFirst = nil) or (@FSourcePlugin.FVFSListNext = nil) or (@FSourcePlugin.FVFSListClose = nil) then begin + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'File listing not supported by the VFS module.'); Exit; end; - - repeat + FError := nil; + P := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), FollowSymlinks, AddFullPath, @FError); + while (P <> nil) and (BreakProcessingType <> 2) do begin if (strlen(P^.FName) > 0) and (AddDotFiles or (P^.FName[0] <> '.')) then begin Item := GetDataItemFromVFSItem(P); List.Add(Item); @@ -475,14 +470,22 @@ begin if P^.FName <> nil then real_libc_free(P^.FName); if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); - memset(P, 0, sizeof(TVFSItem)); - Res := FSourcePlugin.FVFSListNext(FGlobs, P); - until (Res <> cVFS_OK) or (BreakProcessingType = 2); - if BreakProcessingType <> 0 then DebugMsg(['^^VFS (WW): GetListing: stopped by BreakProcessing']); - + real_libc_free(P); + P := FSourcePlugin.FVFSListNext(FGlobs, @FError); + end; + Result := FError = nil; + if BreakProcessingType <> 0 then begin + DebugMsg(['^^VFS (WW): GetListing: stopped by BreakProcessing']); + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_CANCELLED), '%s', 'The operation has been cancelled.'); + Result := False; + end else begin + if (Error <> nil) and (FError <> nil) then + Error^ := g_error_copy(FError); + end; + if FError <> nil then + g_error_free(FError); real_libc_free(P); - FSourcePlugin.FVFSListClose(FGlobs); - if Res <> cVFS_Not_More_Files then Result := Res; + FSourcePlugin.FVFSListClose(FGlobs, nil); except on E: Exception do DebugMsg(['^^VFS (EE): GetListing: Exception: ', E.Message]); @@ -491,18 +494,19 @@ begin DebugMsg(['^^VFS (II): GetListing end.']); end; -function TVFSEngine.GetFileInfo(const APath: string; FollowSymlinks, AddFullPath: boolean): PDataItem; +function TVFSEngine.GetFileInfo(const APath: string; FollowSymlinks, AddFullPath: boolean; Error: PPGError): PDataItem; var P: PVFSItem; - Res: integer; begin DebugMsg(['^^VFS (II): GetFileInfo begin']); Result := nil; - if @FSourcePlugin.FVFSFileInfo = nil then Exit; + + if @FSourcePlugin.FVFSFileInfo = nil then begin + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Querying file info is not supported by the VFS module.'); + Exit; + end; try - P := real_libc_malloc(sizeof(TVFSItem)); - memset(P, 0, sizeof(TVFSItem)); - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P, FollowSymlinks, AddFullPath); - if Res = cVFS_OK then + P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), FollowSymlinks, AddFullPath, Error); + if P <> nil then Result := GetDataItemFromVFSItem(P); if P^.FName <> nil then real_libc_free(P^.FName); if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); @@ -527,13 +531,12 @@ begin AFSSize := -1; AFSFree := -1; AFSName := nil; - if FSourcePlugin.FVFSGetFileSystemInfo(FGlobs, PChar(APath), @AFSSize, @AFSFree, @AFSName) = cVFS_OK then begin - FSSize := AFSSize; - FSFree := AFSFree; - if AFSName <> nil then begin - FSName := string(AFSName); - real_libc_free(AFSName); - end; + FSourcePlugin.FVFSGetFileSystemInfo(FGlobs, PChar(APath), @AFSSize, @AFSFree, @AFSName); + FSSize := AFSSize; + FSFree := AFSFree; + if AFSName <> nil then begin + FSName := string(AFSName); + real_libc_free(AFSName); end; end; end; @@ -546,7 +549,7 @@ end; function TVFSEngine.FileCanRun(const FileName: string): boolean; var Item: PDataItem; begin - Item := GetFileInfo(FileName, True, True); + Item := GetFileInfo(FileName, True, True, nil); Result := (Item <> nil) and Item^.IsExecutable; FreeDataItem(Item); end; @@ -577,26 +580,23 @@ begin end; end; -function TVFSEngine.ChangeDir(const NewPath: string): integer; +function TVFSEngine.ChangeDir(const NewPath: string; Error: PPGError): boolean; begin - DebugMsg(['^^VFS (II): ChangeDir begin']); - Result := 0; + Result := False; try - Result := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(NewPath)); -// Sleep(3000); + Result := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(NewPath), Error); except on E: Exception do DebugMsg(['^^VFS (EE): ChangeDir: Exception: ', E.Message]); end; - DebugMsg(['^^VFS (II): ChangeDir end.']); end; -function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): integer; +function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; begin - Result := ERRNoAccess; + 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); + Result := ChangeDir(NewPath, Error); if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; @@ -604,7 +604,7 @@ end; procedure TVFSEngine.SetPath(Value: string); begin - ChangeDir(Value); + ChangeDir(Value, nil); end; function TVFSEngine.FileExists(const FileName: string; FollowSymlinks: boolean): boolean; @@ -614,9 +614,8 @@ begin if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then Exit; try - P := real_libc_malloc(sizeof(TVFSItem)); - memset(P, 0, sizeof(TVFSItem)); - Result := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), P, FollowSymlinks, False) = cVFS_OK; + P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil); + Result := P <> nil; real_libc_free(P); except on E: Exception do @@ -626,16 +625,13 @@ end; function TVFSEngine.DirectoryExists(const FileName: string; FollowSymlinks: boolean): boolean; var P: PVFSItem; - Res: integer; begin Result := False; if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then Exit; try - P := real_libc_malloc(sizeof(TVFSItem)); - memset(P, 0, sizeof(TVFSItem)); - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), P, FollowSymlinks, False); - Result := (Res = cVFS_OK) and (TVFSItemType(P^.ItemType) = vDirectory); + P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil); + Result := (P <> nil) and (TVFSItemType(P^.ItemType) = vDirectory); real_libc_free(P); except on E: Exception do @@ -643,46 +639,74 @@ begin end; end; -function TVFSEngine.MakeDir(const NewDir: string): integer; +function TVFSEngine.MakeDir(const NewDir: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSMkDir <> nil then Result := FSourcePlugin.FVFSMkDir(FGlobs, PChar(NewDir)) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSMkDir <> nil then + Result := FSourcePlugin.FVFSMkDir(FGlobs, PChar(NewDir), Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Creating directories is not supported by the VFS module.'); + end; end; -function TVFSEngine.Remove(const APath: string): integer; +function TVFSEngine.Remove(const APath: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSRemove <> nil then Result := FSourcePlugin.FVFSRemove(FGlobs, PChar(APath)) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSRemove <> nil then + Result := FSourcePlugin.FVFSRemove(FGlobs, PChar(APath), Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Removing files is not supported by the VFS module.'); + end; end; -function TVFSEngine.RenameFile(const SourceFile, DestFile: string): integer; +function TVFSEngine.RenameFile(const SourceFile, DestFile: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSRename <> nil then Result := FSourcePlugin.FVFSRename(FGlobs, PChar(SourceFile), PChar(DestFile)) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSRename <> nil then + Result := FSourcePlugin.FVFSRename(FGlobs, PChar(SourceFile), PChar(DestFile), Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Renaming files is not supported by the VFS module.'); + end; end; -function TVFSEngine.MakeSymLink(const NewFileName, PointTo: string): integer; +function TVFSEngine.MakeSymLink(const NewFileName, PointTo: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSMakeSymLink <> nil then Result := FSourcePlugin.FVFSMakeSymLink(FGlobs, PChar(NewFileName), PChar(PointTo)) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSMakeSymLink <> nil then + Result := FSourcePlugin.FVFSMakeSymLink(FGlobs, PChar(NewFileName), PChar(PointTo), Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Creating symbolic links is not supported by the VFS module.'); + end; end; -function TVFSEngine.Chmod(const FileName: string; Mode: cuLong): integer; +function TVFSEngine.Chmod(const FileName: string; Mode: cuLong; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChmod <> nil then Result := FSourcePlugin.FVFSChmod(FGlobs, PChar(FileName), Mode) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSChmod <> nil then + Result := FSourcePlugin.FVFSChmod(FGlobs, PChar(FileName), Mode, Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Chmod is not supported by the VFS module.'); + end; end; -function TVFSEngine.Chown(const FileName: string; UID, GID: cuLong): integer; +function TVFSEngine.Chown(const FileName: string; UID, GID: cuLong; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChown <> nil then Result := FSourcePlugin.FVFSChown(FGlobs, PChar(FileName), UID, GID) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSChown <> nil then + Result := FSourcePlugin.FVFSChown(FGlobs, PChar(FileName), UID, GID, Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Chown is not supported by the VFS module.'); + end; end; -function TVFSEngine.ChangeTimes(const APath: string; mtime, atime: time_t): integer; +function TVFSEngine.ChangeTimes(const APath: string; mtime, atime: time_t; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChangeTimes <> nil then Result := FSourcePlugin.FVFSChangeTimes(FGlobs, PChar(APath), mtime, atime) - else Result := cVFS_Failed; + if @FSourcePlugin.FVFSChangeTimes <> nil then + Result := FSourcePlugin.FVFSChangeTimes(FGlobs, PChar(APath), mtime, atime, Error) + else begin + Result := False; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Changing timestamps is not supported by the VFS module.'); + end; end; function TVFSEngine.GetDirSize(const APath: string): Int64; @@ -719,46 +743,51 @@ begin else Result := True; end; -function TVFSEngine.OpenFile(const APath: string; Mode: integer; var Error: integer): TEngineFileDes; -var i: integer; +function TVFSEngine.OpenFile(const APath: string; Mode: integer; Error: PPGError): TEngineFileDes; begin - if @FSourcePlugin.FVFSOpenFile <> nil then begin - Result := FSourcePlugin.FVFSOpenFile(FGlobs, PChar(APath), Mode, @i); - Error := i; - end else Result := nil; + if @FSourcePlugin.FVFSOpenFile <> nil then + Result := FSourcePlugin.FVFSOpenFile(FGlobs, PChar(APath), Mode, Error) + else begin + Result := nil; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Manual opening files is not supported by the VFS module.'); + end; end; -function TVFSEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; var Error: integer): integer; -var i: integer; +function TVFSEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; Error: PPGError): integer; begin - if @FSourcePlugin.FVFSReadFile <> nil then begin - Result := FSourcePlugin.FVFSReadFile(FGlobs, FileDescriptor, Buffer, ABlockSize, @i); - Error := i; - end else Result := -1; + if @FSourcePlugin.FVFSReadFile <> nil then + Result := FSourcePlugin.FVFSReadFile(FGlobs, FileDescriptor, Buffer, ABlockSize, Error) + else begin + Result := -1; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Manual read is not supported by the VFS module.'); + end; end; -function TVFSEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; var Error: integer): integer; -var i: integer; +function TVFSEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; Error: PPGError): integer; begin - if @FSourcePlugin.FVFSWriteFile <> nil then begin - Result := FSourcePlugin.FVFSWriteFile(FGlobs, FileDescriptor, Buffer, BytesCount, @i); - Error := i; - end else Result := -1; + if @FSourcePlugin.FVFSWriteFile <> nil then + Result := FSourcePlugin.FVFSWriteFile(FGlobs, FileDescriptor, Buffer, BytesCount, Error) + else begin + Result := -1; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Manual write is not supported by the VFS module.'); + end; end; -function TVFSEngine.CloseFile(const FileDescriptor: TEngineFileDes): integer; +function TVFSEngine.CloseFile(const FileDescriptor: TEngineFileDes; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSCloseFile <> nil then Result := FSourcePlugin.FVFSCloseFile(FGlobs, FileDescriptor) - else Result := 0; + if @FSourcePlugin.FVFSCloseFile <> nil then + Result := FSourcePlugin.FVFSCloseFile(FGlobs, FileDescriptor, nil) + else Result := False; end; -function TVFSEngine.FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; var Error: integer): Int64; -var i: integer; +function TVFSEngine.FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; Error: PPGError): Int64; begin - if @FSourcePlugin.FVFSFileSeek <> nil then begin - Result := FSourcePlugin.FVFSFileSeek(FGlobs, FileDescriptor, AbsoluteOffset, @i); - Error := i; - end else Result := -1; + if @FSourcePlugin.FVFSFileSeek <> nil then + Result := FSourcePlugin.FVFSFileSeek(FGlobs, FileDescriptor, AbsoluteOffset, Error) + else begin + Result := -1; + g_set_error(Error, G_IO_ERROR, gint(G_IO_ERROR_NOT_SUPPORTED), '%s', 'Manual seek is not supported by the VFS module.'); + end; end; function TVFSEngine.TwoSameFiles(const Path1, Path2: string; FollowSymlinks: boolean): boolean; @@ -770,129 +799,123 @@ end; (********************************************************************************************************************************) -function TVFSEngine.CopyFileIn(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; +function TVFSEngine.CopyFileIn(const SourceFile, DestFile: string; Append: boolean; ProgressFunc: TEngineProgressFunc; Sender: Pointer): boolean; begin - Result := StartCopyOperation(Sender, ErrorFunc, nil, nil, nil, nil); - Result := Result and CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append); - Result := Result and StopCopyOperation(Sender, ErrorFunc); + DebugMsg(['** (WW): deprecated method CopyFileIn called from a TVFSEngine instance!']); + Result := StartCopyOperation(nil, nil, nil, nil); + Result := Result and CopyFileInEx(SourceFile, DestFile, Append); + Result := Result and StopCopyOperation(nil, nil); end; -function TVFSEngine.CopyFileOut(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; +function TVFSEngine.CopyFileOut(const SourceFile, DestFile: string; Append: boolean; ProgressFunc: TEngineProgressFunc; Sender: Pointer): boolean; begin - Result := StartCopyOperation(Sender, ErrorFunc, nil, nil, nil, nil); - Result := Result and CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append); - Result := Result and StopCopyOperation(Sender, ErrorFunc); + DebugMsg(['** (WW): deprecated method CopyFileOut called from a TVFSEngine instance!']); + Result := StartCopyOperation(nil, nil, nil, nil); + Result := Result and CopyFileOutEx(SourceFile, DestFile, Append); + Result := Result and StopCopyOperation(nil, nil); end; -function TVFSEngine.CopyFileOutEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; -var Res: TVFSResult; +function TVFSEngine.CopyFileOutEx(const SourceFile, DestFile: string; Append: boolean): boolean; +var Error: PGError; + ACopyProgressCallback: TVFSProgressCallback; begin Result := False; try - if @FSourcePlugin.FVFSCopyToLocal <> nil then begin - try - Res := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append); - except - on E: Exception do begin - DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOut(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); - Res := cVFS_WriteErr; - end; + Error := nil; + if @FSourcePlugin.FVFSCopyToLocal <> nil then + Result := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error) + 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 + if FCopyProgressCallback <> nil then begin + @ACopyProgressCallback := FCopyProgressCallback; + Result := ACopyProgressCallback(0, Error, FCopyCallbackData); end; - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, SourceFile); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, DestFile); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, SourceFile); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, SourceFile); - end; - end else Result := False; + g_error_free(Error); + end; except - on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOut(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); + on E: Exception do begin + DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOutEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]); + Result := False; + end; end; end; -function TVFSEngine.CopyFileInEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; -var Res: TVFSResult; +function TVFSEngine.CopyFileInEx(const SourceFile, DestFile: string; Append: boolean): boolean; +var Error: PGError; +ACopyProgressCallback: TVFSProgressCallback; begin Result := False; try - if @FSourcePlugin.FVFSCopyFromLocal <> nil then begin - try - Res := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append); - except - on E: Exception do begin - DebugMsg(['*** Exception raised in TVFSEngine.CopyFileIn(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); - Res := cVFS_WriteErr; - end; + Error := nil; + if @FSourcePlugin.FVFSCopyFromLocal <> nil then + Result := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, @Error) + 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 + if FCopyProgressCallback <> nil then begin + @ACopyProgressCallback := FCopyProgressCallback; + Result := ACopyProgressCallback(0, Error, FCopyCallbackData); end; - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, SourceFile); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, DestFile); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, SourceFile); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, SourceFile); - end; - end else Result := False; + g_error_free(Error); + end; except - on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.CopyFileIn(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); + on E: Exception do begin + DebugMsg(['*** Exception raised in TVFSEngine.CopyFileInEx(SourceFile=', SourceFile, ', DestFile=', DestFile, ', Append=', Append,'): (', E.ClassName, '): ', E.Message]); + Result := False; + end; end; end; -function TVFSEngine.StartCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; -var Res: TVFSResult; +function TVFSEngine.StartCopyOperation(AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; +var Error: PGError; begin Result := not ArchiveMode; try if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); + FCopyProgressCallback := ProgressCallback; + FCopyCallbackData := CallbackData; if ArchiveMode then begin - if @FSourcePlugin.FVFSStartCopyOperation <> nil then begin - Res := FSourcePlugin.FVFSStartCopyOperation(FGlobs); - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StartCopyOperation'); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StartCopyOperation'); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StartCopyOperation'); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StartCopyOperation'); - end; - end else - ErrorFunc(Sender, 2, 0, 'StartCopyOperation not supported'); + Error := nil; + if @FSourcePlugin.FVFSStartCopyOperation <> nil then + Result := FSourcePlugin.FVFSStartCopyOperation(FGlobs, @Error) + 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 + if ProgressCallback <> nil then + Result := ProgressCallback^(0, Error, CallbackData); + g_error_free(Error); + end; end; except - on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StartCopyOperation(Sender=', QWord(Sender), '): (', E.ClassName, '): ', E.Message]); + on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StartCopyOperation(CallbackData=', CallbackData, '): (', E.ClassName, '): ', E.Message]); end; end; -function TVFSEngine.StopCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc): boolean; -var Res: TVFSResult; +function TVFSEngine.StopCopyOperation(ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; +var Error: PGError; begin Result := not ArchiveMode; try if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); if ArchiveMode then begin - if @FSourcePlugin.FVFSStopCopyOperation <> nil then begin - Res := FSourcePlugin.FVFSStopCopyOperation(FGlobs); - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StopCopyOperation'); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StopCopyOperation'); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StopCopyOperation'); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StopCopyOperation'); - end; - end else - ErrorFunc(Sender, 5, 0, 'StopCopyOperation not supported'); + Error := nil; + if @FSourcePlugin.FVFSStopCopyOperation <> nil then + Result := FSourcePlugin.FVFSStopCopyOperation(FGlobs, @Error) + 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 + if ProgressCallback <> nil then + Result := ProgressCallback^(0, Error, CallbackData); + g_error_free(Error); + end; end; + FCopyProgressCallback := nil; + FCopyCallbackData := nil; except - on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StopCopyOperation(Sender=', QWord(Sender), '): (', E.ClassName, '): ', E.Message]); + on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StopCopyOperation(CallbackData=', CallbackData, '): (', E.ClassName, '): ', E.Message]); end; end; diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas index 8beacdd..9ed0844 100644 --- a/vfs/uVFSprototypes.pas +++ b/vfs/uVFSprototypes.pas @@ -36,24 +36,7 @@ uses glib2; const cVFSVersion = 5; // current version of the VFS API - // Error codes (TVFSResult) - cVFS_OK = 0; - cVFS_Failed = 1; // also No such file - cVFS_Cancelled = 2; - cVFS_Not_Supported = 3; - cVFS_Not_More_Files = 4; // returned while directory listing - cVFS_ReadErr = 5; - cVFS_WriteErr = 6; // also ReadOnlyFileSystem - cVFS_LoginFailed = 7; - cVFS_PermissionDenied = 8; - cVFS_NoSpaceLeft = 9; - cVFS_mallocFailed = 10; - cVFS_BadPassword = 11; - cVFS_MissingVolume = 12; - cVFS_CorruptedArchive = 13; - - - // Open modes (for VFSOpenFile function) + // Open modes (for VFSOpenFile function) cVFS_OpenRead = 0; cVFS_OpenWrite = 1; cVFS_OpenAppend = 2; @@ -76,8 +59,6 @@ const type - TVFSResult = longint; - // Plugin private data for each connection/instance TVFSGlobs = Pointer; @@ -94,7 +75,6 @@ type TVFSItemType = (vRegular=0, vChardev=1, vBlockdev=2, vDirectory=3, vFifo=4, vSock=5, vOther=6); - PVFSItem = ^TVFSItem; TVFSItem = record FName: PChar; @@ -149,10 +129,14 @@ type password_save: PVFSPasswordSave; user_data: Pointer): gboolean; cdecl; - // Return False to break the operation + // Progress callback, return False to break the copy process + // If an Error is set, returning True means to ignore error (don't delete broken file if possible) + // If an Error is set, Position may contain random value + // Do not free Error, it belongs to the copy operation PVFSProgressCallback = ^TVFSProgressCallback; + // Keep in sync with UCoreWorkers.pas/vfs_progress_callback TVFSProgressCallback = function (position: guint64; - max: guint64; + error: PGError; user_data: Pointer): gboolean; cdecl; type @@ -192,33 +176,33 @@ type // Opens specified archive. This will also switch engine into an archiving mode - TVFSOpenArchive = function (g:TVFSGlobs; const sName: PChar): TVFSResult; cdecl; + TVFSOpenArchive = function (g:TVFSGlobs; const sName: PChar; Error: PPGError): gboolean; cdecl; // Opens specified network location. This will also switch engine into a networking mode // In case of URI, do not supply password encoded in the string; plugin will automatically spawn the TVFSAskPasswordCallback callback when needed - TVFSOpenURI = function (g:TVFSGlobs; const sURI: PChar): TVFSResult; cdecl; + TVFSOpenURI = function (g:TVFSGlobs; const sURI: PChar; Error: PPGError): gboolean; cdecl; // Closes the file or connection to the server - TVFSClose = function (g:TVFSGlobs): TVFSResult; cdecl; + TVFSClose = function (g:TVFSGlobs; Error: PPGError): gboolean; cdecl; // These functions serves for listing contents of a directory // Before calling VFSListFirst, it is recommended to change target directory (VFSChangeDir) to check it really exists // First call the VFSListFirst function and then repeat call of VFSListNext until it returns NULL. // Then call VFSListClose to make cleanup - TVFSListFirst = function (g:TVFSGlobs; const sDir: PChar; VFSItem: PVFSItem; FollowSymlinks, AddFullPath: gboolean): TVFSResult; cdecl; - TVFSListNext = function (g:TVFSGlobs; VFSItem: PVFSItem): TVFSResult; cdecl; - TVFSListClose = function (g:TVFSGlobs): TVFSResult; cdecl; + TVFSListFirst = function (g:TVFSGlobs; const sDir: PChar; FollowSymlinks, AddFullPath: gboolean; Error: PPGError): PVFSItem; cdecl; + TVFSListNext = function (g:TVFSGlobs; Error: PPGError): PVFSItem; cdecl; + TVFSListClose = function (g:TVFSGlobs; Error: PPGError): gboolean; cdecl; // Gets a single info item without need to list a whole directory - TVFSFileInfo = function (g:TVFSGlobs; const AFileName: PChar; VFSItem: PVFSItem; FollowSymlinks, AddFullPath: gboolean): TVFSResult; cdecl; + TVFSFileInfo = function (g:TVFSGlobs; const AFileName: PChar; FollowSymlinks, AddFullPath: gboolean; Error: PPGError): PVFSItem; cdecl; // Try to change directory, checks real access - TVFSChangeDir = function (g:TVFSGlobs; const NewPath: PChar): TVFSResult; cdecl; + TVFSChangeDir = function (g:TVFSGlobs; const NewPath: PChar; Error: PPGError): gboolean; cdecl; // Returns current working path, tuxcmd will take care of memory deallocation TVFSGetPath = function (g:TVFSGlobs): PChar; cdecl; // Returns the current working path in the URI form, tuxcmd will take care of memory deallocation TVFSGetPathURI = function (g:TVFSGlobs): PChar; cdecl; // Gets filesystem info; tuxcmd will take care of memory deallocation - TVFSGetFileSystemInfo = function (g:TVFSGlobs; const APath: PChar; FSSize, FSFree: PInt64; FSLabel: PPChar): TVFSResult; cdecl; + TVFSGetFileSystemInfo = procedure (g:TVFSGlobs; const APath: PChar; FSSize, FSFree: PInt64; FSLabel: PPChar); cdecl; TVFSIsOnSameFS = function (g:TVFSGlobs; const Path1, Path2: PChar; FollowSymlinks: gboolean): gboolean; cdecl; // Checks if the two files are simmilar (used to test the case-insensitive filesystem - or hardlinks) TVFSTwoSameFiles = function (g:TVFSGlobs; const Path1, Path2: PChar; FollowSymlinks: gboolean): gboolean; cdecl; @@ -228,34 +212,34 @@ type TVFSBreakGetDirSize = procedure (g:TVFSGlobs); cdecl; // Operations - TVFSMkDir = function (g:TVFSGlobs; const sDirName: PChar): TVFSResult; cdecl; + TVFSMkDir = function (g:TVFSGlobs; const sDirName: PChar; Error: PPGError): gboolean; cdecl; // Rename/Move, the two files/directories have to be on the same filesystem (do manual copy and delete otherway) - TVFSRename = function (g:TVFSGlobs; const sSrcName, sDstName: PChar): TVFSResult; cdecl; + TVFSRename = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Error: PPGError): gboolean; cdecl; // Removes file/directory (empty only!) - TVFSRemove = function (g:TVFSGlobs; const APath: PChar): TVFSResult; cdecl; - TVFSMakeSymLink = function (g:TVFSGlobs; const NewFileName, PointTo: PChar): TVFSResult; cdecl; + TVFSRemove = function (g:TVFSGlobs; const APath: PChar; Error: PPGError): gboolean; cdecl; + TVFSMakeSymLink = function (g:TVFSGlobs; const NewFileName, PointTo: PChar; Error: PPGError): gboolean; cdecl; // Mode is classic unix format (glibc) - a bit mask - TVFSChmod = function (g:TVFSGlobs; const FileName: PChar; Mode: guint32): TVFSResult; cdecl; - TVFSChown = function (g:TVFSGlobs; const FileName: PChar; UID, GID: guint32): TVFSResult; cdecl; + TVFSChmod = function (g:TVFSGlobs; const FileName: PChar; Mode: guint32; Error: PPGError): gboolean; cdecl; + TVFSChown = function (g:TVFSGlobs; const FileName: PChar; UID, GID: guint32; Error: PPGError): gboolean; cdecl; // Changes times for the file/directory - mtime and atime are __time_t parameters (glibc) - TVFSChangeTimes = function (g:TVFSGlobs; const APath: PChar; mtime, atime: guint32): TVFSResult; cdecl; + TVFSChangeTimes = function (g:TVFSGlobs; const APath: PChar; mtime, atime: guint32; Error: PPGError): gboolean; cdecl; // Performs the copy process from inside of module to local filesystem // (thus sSrcName is a path from inside of module and sDstName is path in the local filesystem where the file should be copied) // Note: if you need to transfer a file between two VFS modules, you need to do it manually - // - either first copy to local FS or use the Open, Read, Write functions of the module (NOTE: both VFS modules have to support these functions) - TVFSCopyToLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: gboolean): TVFSResult; cdecl; + TVFSCopyToLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: gboolean; Error: PPGError): gboolean; cdecl; // Performs the copy process from local filesystem into the module - TVFSCopyFromLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: gboolean): TVFSResult; cdecl; - // Start the copy operation - open the archive and prepare internal structures - TVFSStartCopyOperation = function (g:TVFSGlobs): TVFSResult; cdecl; - // Stop the copy operation - close the archive and free memory - TVFSStopCopyOperation = function (g:TVFSGlobs): TVFSResult; cdecl; + TVFSCopyFromLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: gboolean; Error: PPGError): gboolean; cdecl; + // Start the copy operation - open the archive and prepare internal structures (called only in archive mode) + TVFSStartCopyOperation = function (g:TVFSGlobs; Error: PPGError): gboolean; cdecl; + // Stop the copy operation - close the archive and free memory (called only in archive mode) + TVFSStopCopyOperation = function (g:TVFSGlobs; Error: PPGError): gboolean; cdecl; // TODO: Prototype function for packing new files into archive - TVFSPack = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; CompressionLevel: integer; const Password: PChar): TVFSResult; cdecl; + TVFSPack = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; CompressionLevel: integer; const Password: PChar; Error: PPGError): gboolean; cdecl; // TODO: not implemented at all @@ -263,14 +247,14 @@ type // There is a TVFSFileDes object which identifies the processed file (filedescriptor) // All these functions needs a pointer to an int variable to store the error code // NOTE: not all modules could support this set of functions due to its design (unable to set a solid block size) - TVFSOpenFile = function (g:TVFSGlobs; const APath: PChar; Mode: integer; Error: Pinteger): TVFSFileDes; cdecl; + TVFSOpenFile = function (g:TVFSGlobs; const APath: PChar; Mode: integer; Error: PPGError): TVFSFileDes; cdecl; // Opens a file or creates new (the values for the Mode parameter are described above) and returns the assigned filedescriptor - TVFSReadFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; ABlockSize: integer; Error: Pinteger): integer; cdecl; + TVFSReadFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; ABlockSize: integer; Error: PPGError): integer; cdecl; // Returns number of bytes read; the buffer needs to be allocated by a blocksize (set it by VFSSetBlockSize function) - TVFSWriteFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; BytesCount: integer; Error: Pinteger): integer; cdecl; + TVFSWriteFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; BytesCount: integer; Error: PPGError): integer; cdecl; // Returns number of bytes written - TVFSCloseFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes): TVFSResult; cdecl; - TVFSFileSeek = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; const AbsoluteOffset: Int64; Error: Pinteger): Int64; cdecl; + TVFSCloseFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Error: PPGError): gboolean; cdecl; + TVFSFileSeek = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; const AbsoluteOffset: Int64; Error: PPGError): Int64; cdecl; // Sets the position in the file from the start and returns real current position |
