diff options
Diffstat (limited to 'vfs')
| -rw-r--r-- | vfs/UVFSCore.pas | 541 | ||||
| -rw-r--r-- | vfs/uVFSprototypes.pas | 240 |
2 files changed, 276 insertions, 505 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index a4bedf0..90b31b5 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -21,7 +21,7 @@ unit UVFSCore; interface -uses GTKForms, ULibc, Classes, uVFSprototypes, UEngines, UCoreUtils; +uses GTKForms, ULibc, glib2, Classes, uVFSprototypes, UEngines, UCoreUtils; type @@ -40,9 +40,7 @@ type FVFSChangeDir: TVFSChangeDir; FVFSGetPath: TVFSGetPath; FVFSGetPathURI: TVFSGetPathURI; - FVFSGetFileSystemSize: TVFSGetFileSystemSize; - FVFSGetFileSystemFree: TVFSGetFileSystemFree; - FVFSFileExists: TVFSFileExists; + FVFSGetFileSystemInfo: TVFSGetFileSystemInfo; FVFSFileInfo: TVFSFileInfo; FVFSMkDir: TVFSMkDir; FVFSRemove: TVFSRemove; @@ -90,13 +88,14 @@ type TVFSEngine = class(TPanelEngine) private + BreakProcessingType: integer; FGlobs: Pointer; FSourcePlugin: TVFSPlugin; FBlockSize: Cardinal; - BreakProcessingKind: integer; FArchiveMode: boolean; FArchivePath: string; function GetPluginID: string; + function GetDataItemFromVFSItem(P: PVFSItem): PDataItem; public Password: string; PasswordUsed: boolean; @@ -104,58 +103,60 @@ type OpenedFromQuickConnect: boolean; CustomPluginIDSave: string; constructor Create(SourcePlugin: TVFSPlugin); - function VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; - function VFSOpenEx(OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult; - function VFSClose: boolean; - destructor Destroy; override; - function GetListing(var List: TList; const AddDotFiles: boolean): integer; override; - function GetListing(var List: TList; const AddDotFiles: boolean; APath: string): integer; 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 ChangeDir(const NewPath: string): integer; override; - function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): integer; - function ExplicitChDir(const NewPath: string): integer; override; - function GetFileSystemSize: Int64; override; - function GetFileSystemSize(const APath: string): Int64; override; - function GetFileSystemFree: Int64; override; - function GetFileSystemFree(const APath: string): Int64; override; - function MakeDir(const NewDir: string): integer; override; - function GetDirSize(APath: string): Int64; override; - function Remove(APath: string): integer; override; - procedure FillDirFiles(APath: string; List: TList; ALevel: word); override; - function GetFileInfoSL(APath: string): PDataItemSL; override; - function FileExists(const FileName: string; const Use_lstat: boolean = False): Boolean; override; - function DirectoryExists(const FileName: string; const Use_lstat: boolean = False): Boolean; override; - function MakeSymLink(const NewFileName, PointTo: string): integer; override; - function Chmod(const FileName: string; const Mode: integer): integer; override; - function Chown(const FileName: string; const UID, GID: integer): integer; override; + function GetPath: string; override; + procedure SetPath(Value: string); override; + + function GetDirSize(const APath: string): Int64; override; procedure BreakProcessing(ProcessingKind: integer); override; - function RenameFile(SourceFile, DestFile: string): integer; override; - function ChangeTimes(APath: string; mtime, atime: Int64): integer; override; + function FileExists(const FileName: string; FollowSymlinks: boolean): boolean; override; + function DirectoryExists(const FileName: string; FollowSymlinks: boolean): boolean; override; procedure GetFileSystemInfo(const APath: string; var FSSize, FSFree: Int64; var FSName: string); override; - function OpenFile(const APath: string; Mode: integer; var Error: integer): TEngineFileDes; override; + 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 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 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 IsOnROMedium(const FileName: string): boolean; override; - function FileCanRun(const FileName: string): boolean; override; - function GetPath: string; override; - procedure SetPath(Value: string); override; - function GetPathURI: string; - function GetBlockSize: Cardinal; override; - procedure SetBlockSize(Value: Cardinal); override; - function CopyFileIn(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override; - function CopyFileOut(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override; - function CopyFileInEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; - AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; - function CopyFileOutEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; - AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; - function IsOnSameFS(const Path1, Path2: string): boolean; override; - function TwoSameFiles(const Path1, Path2: string): boolean; 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 GetPathURI: string; function GetPasswordRequired: boolean; procedure ResetPassword; + + // the callbacks here are used for next volume prompts, password prompts (encrypted archives) - as long as this is specific to each file + function CopyFileInEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; + AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; + function CopyFileOutEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; + AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; published property Path: string read GetPath write SetPath; property BlockSize: Cardinal read GetBlockSize write SetBlockSize; @@ -215,9 +216,7 @@ begin @FVFSGetPath := dlsym(ModuleHandle, 'VFSGetPath'); @FVFSGetPathURI := dlsym(ModuleHandle, 'VFSGetPathURI'); @FVFSChangeDir := dlsym(ModuleHandle, 'VFSChangeDir'); - @FVFSGetFileSystemSize := dlsym(ModuleHandle, 'VFSGetFileSystemSize'); - @FVFSGetFileSystemFree := dlsym(ModuleHandle, 'VFSGetFileSystemFree'); - @FVFSFileExists := dlsym(ModuleHandle, 'VFSFileExists'); + @FVFSGetFileSystemInfo := dlsym(ModuleHandle, 'VFSGetFileSystemInfo'); @FVFSFileInfo := dlsym(ModuleHandle, 'VFSFileInfo'); @FVFSMkDir := dlsym(ModuleHandle, 'VFSMkDir'); @FVFSRemove := dlsym(ModuleHandle, 'VFSRemove'); @@ -343,11 +342,11 @@ end; constructor TVFSEngine.Create(SourcePlugin: TVFSPlugin); begin inherited Create; + BreakProcessingType := 0; FSourcePlugin := SourcePlugin; FBlockSize := 65536; FArchiveMode := False; FArchivePath := ''; - BreakProcessingKind := 0; FGlobs := nil; Password := ''; PasswordUsed := False; @@ -370,7 +369,7 @@ begin end; end; -function TVFSEngine.VFSOpenURI(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): boolean; begin Result := False; if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenURI <> nil) then begin @@ -384,7 +383,7 @@ begin end; end; -function TVFSEngine.VFSOpenEx(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): TVFSResult; begin Result := cVFS_OK; if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenArchive <> nil) then begin @@ -399,6 +398,7 @@ begin end; end; +(********************************************************************************************************************************) function TVFSEngine.VFSClose: boolean; begin Result := False; @@ -406,20 +406,52 @@ begin then Result := FSourcePlugin.FVFSClose(FGlobs) = cVFS_OK; end; -function TVFSEngine.GetListing(var List: TList; const AddDotFiles: boolean; APath: string): integer; +function TVFSEngine.GetDataItemFromVFSItem(P: PVFSItem): PDataItem; +var Item: PDataItem; +begin + Item := malloc(sizeof(TDataItem)); + memset(Item, 0, sizeof(TDataItem)); + Item^.UpDir := False; + Item^.Selected := False; + + Item^.FName := g_strdup(P^.FName); + Item^.FDisplayName := g_strdup(P^.FDisplayName); + Item^.LnkPointTo := g_strdup(P^.sLinkTo); + Item^.Mode := P^.iMode; + Item^.IsDotFile := (Length(P^.FName) > 1) and (P^.FName[0] = '.'); + Item^.IsExecutable := (P^.iMode and S_IXUSR) = S_IXUSR; + Item^.IsDir := TVFSItemType(P^.ItemType) = vDirectory; + Item^.IsLnk := P^.IsLink; + Item^.IsBlk := TVFSItemType(P^.ItemType) = vBlockdev; + Item^.IsChr := TVFSItemType(P^.ItemType) = vChardev; + Item^.IsFIFO := TVFSItemType(P^.ItemType) = vFifo; + Item^.IsSock := TVFSItemType(P^.ItemType) = vSock; + Item^.mtime := P^.m_time; + Item^.atime := P^.a_time; + Item^.ctime := P^.c_time; + Item^.UID := P^.iUID; + Item^.GID := P^.iGID; + Item^.Size := P^.iSize; + Item^.PackedSize := P^.iPackedSize; + + Result := Item; +end; + +function TVFSEngine.GetListing(List: TList; const APath: string; AddDotFiles, FollowSymlinks, AddFullPath: boolean): integer; var P: PVFSItem; Item: PDataItem; - i, Res: integer; + Res: integer; begin DebugMsg(['^^VFS (II): GetListing begin']); Result := 0; try - if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); -// DebugMsg(['Item = ', Int64(P)]); -// DebugMsg(['FVFSListFirst']); - Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P); + 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 @@ -429,68 +461,17 @@ begin end; repeat -// DebugMsg(['begin--']); - if AddDotFiles or (not ((Length(P^.FName) > 1) and (P^.FName[0] = '.') and (P^.FName[1] <> '.'))) then begin -// DebugMsg(['Checkpoint 1']); - Item := malloc(SizeOf(TDataItem)); - memset(Item, 0, SizeOf(TDataItem)); -// DebugMsg(['Checkpoint 2']); - for i := 0 to Length(Item^.ColumnData) - 1 do Item^.ColumnData[i] := nil; -// DebugMsg(['Checkpoint 3']); - with Item^ do - try - FName := strdup(P^.FName); - FDisplayName := strdup(P^.FDisplayName); - if P^.sLinkTo <> nil - then begin - LnkPointTo := strdup(P^.sLinkTo); - DebugMsg(['LnkPointTo = ', P^.sLinkTo]); - end else LnkPointTo := nil; - Mode := P^.iMode; -// DebugMsg(['Checkpoint 4']); - IsDotFile := (Length(FName) > 1) and (FName[0] = '.') and (FName[1] <> '.'); - IsDir := TVFSItemType(P^.ItemType) = vDirectory; - IsLnk := TVFSItemType(P^.ItemType) = vSymlink; - IsBlk := TVFSItemType(P^.ItemType) = vBlockdev; - IsChr := TVFSItemType(P^.ItemType) = vChardev; - IsFIFO := TVFSItemType(P^.ItemType) = vFifo; - IsSock := TVFSItemType(P^.ItemType) = vSock; -// DebugMsg(['Checkpoint 5']); - ModifyTime := P^.m_time; -// DebugMsg(['Returned datetime: ', Longword(P^.m_time)]); -// DebugMsg(['Checkpoint 6']); - UID := P^.iUID; -// DebugMsg(['Checkpoint 7']); - GID := P^.iGID; -// DebugMsg(['Checkpoint 8']); - UpDir := False; -// DebugMsg(['Checkpoint 9']); - Selected := False; -// DebugMsg(['Checkpoint 10']); - Size := P^.iSize; -// DebugMsg(['Checkpoint 11']); - List.Add(Item); -// DebugMsg(['Checkpoint 12']); - except - on E: Exception do - DebugMsg(['^^VFS (EE): GetListing: Item-Exception: ', E.Message]); - end; - end; // of if AddDotFiles + if (strlen(P^.FName) > 0) and (AddDotFiles or (P^.FName[0] <> '.')) then begin + Item := GetDataItemFromVFSItem(P); + List.Add(Item); + end; 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); - real_libc_free(P); // Not needed - just zero-erase the memory -// DebugMsg(['Checkpoint 13']); - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); -// DebugMsg(['Item = ', Int64(P)]); -// DebugMsg(['Checkpoint 14']); -// DebugMsg(['FVFSListNext --begin']); - Res := FSourcePlugin.FVFSListNext(FGlobs, PChar(APath), P); -// DebugMsg(['FVFSListNext --end']); -// Sleep(500); - until (Res <> cVFS_OK) or (BreakProcessingKind = 2); - if BreakProcessingKind <> 0 then DebugMsg(['^^VFS (WW): GetListing: stopped by BreakProcessing']); + 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); FSourcePlugin.FVFSListClose(FGlobs); @@ -499,62 +480,67 @@ begin on E: Exception do DebugMsg(['^^VFS (EE): GetListing: Exception: ', E.Message]); end; - BreakProcessingKind := 0; + BreakProcessingType := 0; DebugMsg(['^^VFS (II): GetListing end.']); end; -function TVFSEngine.GetListing(var List: TList; const AddDotFiles: boolean): integer; -begin - Result := GetListing(List, AddDotFiles, GetPath); -end; - -function TVFSEngine.ExplicitChDir(const NewPath: string): integer; -begin - Result := libc_chdir(PChar(NewPath)); - if Result <> 0 then Result := errno; -end; - -function TVFSEngine.GetFileSystemSize: Int64; -begin - Result := GetFileSystemSize(GetPath); -end; - -function TVFSEngine.GetFileSystemSize(const APath: string): Int64; -begin - if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetFileSystemSize <> nil) - then Result := FSourcePlugin.FVFSGetFileSystemSize(FGlobs, PChar(APath)) - else Result := 0; -end; - -function TVFSEngine.GetFileSystemFree: Int64; -begin - Result := GetFileSystemFree(GetPath); -end; - -function TVFSEngine.GetFileSystemFree(const APath: string): Int64; +function TVFSEngine.GetFileInfo(const APath: string; FollowSymlinks, AddFullPath: boolean): PDataItem; +var P: PVFSItem; + Res: integer; begin - if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetFileSystemFree <> nil) - then Result := FSourcePlugin.FVFSGetFileSystemFree(FGlobs, PChar(APath)) - else Result := 0; + DebugMsg(['^^VFS (II): GetFileInfo begin']); + Result := nil; + if @FSourcePlugin.FVFSFileInfo = nil then Exit; + 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 + Result := GetDataItemFromVFSItem(P); + 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); + real_libc_free(P); + except + on E: Exception do + DebugMsg(['^^VFS (EE): GetFileInfo: Exception: ', E.Message]); + end; + DebugMsg(['^^VFS (II): GetFileInfo end.']); end; +(********************************************************************************************************************************) procedure TVFSEngine.GetFileSystemInfo(const APath: string; var FSSize, FSFree: Int64; var FSName: string); +var AFSSize, AFSFree: Int64; + AFSName: PChar; begin - FSSize := GetFileSystemSize(APath); - FSFree := GetFileSystemFree(APath); + FSSize := -1; + FSFree := -1; FSName := 'plugin'; + if @FSourcePlugin.FVFSGetFileSystemInfo <> nil then 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; + end; + end; end; function TVFSEngine.IsOnROMedium(const FileName: string): boolean; begin - Result := True; + Result := FArchiveMode; end; function TVFSEngine.FileCanRun(const FileName: string): boolean; -var Item: PDataItemSL; +var Item: PDataItem; begin - Item := GetFileInfoSL(FileName); - Result := Assigned(Item) and Item^.IsExecutable; + Item := GetFileInfo(FileName, True, True); + Result := (Item <> nil) and Item^.IsExecutable; FreeDataItem(Item); end; @@ -614,81 +600,39 @@ begin ChangeDir(Value); end; -function TVFSEngine.FileExists(const FileName: string; const Use_lstat: boolean = False): Boolean; -begin - if (FGlobs <> nil) and (@FSourcePlugin.FVFSFileExists <> nil) - then Result := FSourcePlugin.FVFSFileExists(FGlobs, PChar(FileName), Use_lstat) - else Result := False; -end; - -function TVFSEngine.DirectoryExists(const FileName: string; const Use_lstat: boolean = False): Boolean; +function TVFSEngine.FileExists(const FileName: string; FollowSymlinks: boolean): boolean; var P: PVFSItem; - Res: integer; begin - if @FSourcePlugin.FVFSFileExists <> nil then begin - Result := FSourcePlugin.FVFSFileExists(FGlobs, PChar(FileName), Use_lstat); - if Result and (@FSourcePlugin.FVFSFileInfo <> nil) then begin - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), P); - if (Res <> cVFS_OK) or (P = nil) or (TVFSItemType(P^.ItemType) <> vDirectory) then Result := False; - real_libc_free(P); - end; - end else Result := False; + Result := False; + 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; + real_libc_free(P); + except + on E: Exception do + DebugMsg(['^^VFS (EE): FileExists: Exception: ', E.Message]); + end; end; -function TVFSEngine.GetFileInfoSL(APath: string): PDataItemSL; +function TVFSEngine.DirectoryExists(const FileName: string; FollowSymlinks: boolean): boolean; var P: PVFSItem; - Item: PDataItemSL; Res: integer; begin - Result := nil; - if @FSourcePlugin.FVFSFileInfo = nil then Exit; - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); - if Res <> cVFS_OK then begin - DebugMsg(['*** VFSFileInfo(', APath, ') failed. Code = ', Res]); + Result := False; + if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then Exit; - end; - try - Item := malloc(SizeOf(TDataItemSL)); - memset(Item, 0, SizeOf(TDataItemSL)); - with Item^ do begin -{ FName := strdup(P^.FName); - FDisplayName := StrToUTF8(P^.FName); } - FName := strdup(PChar(APath)); - - //* TODO - FDisplayName := StrToUTF8(PChar(APath)); - if P^.sLinkTo <> nil then LnkPointTo := strdup(P^.sLinkTo) - else LnkPointTo := nil; - ADestination := nil; - Stage1 := True; - Level := 0; - IsDir := TVFSItemType(P^.ItemType) = vDirectory; - IsLnk := TVFSItemType(P^.ItemType) = vSymlink; - ForceMove := False; -{***} IsOnRO := True; - IsExecutable := P^.iMode and S_IXUSR = S_IXUSR; - Mode := P^.iMode; - ModifyTime := P^.m_time; - mtime := P^.m_time; - atime := P^.a_time; - UID := P^.iUID; - GID := P^.iGID; - Size := P^.iSize; - PackedSize := P^.iPackedSize; - 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); - real_libc_free(P); - end; - Result := Item; + 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); + real_libc_free(P); except - on E: Exception do DebugMsg(['*** TVFSEngine.GetFileInfoSL(APath=', APath, ') -Exception: ', E.Message]); + on E: Exception do + DebugMsg(['^^VFS (EE): FileExists: Exception: ', E.Message]); end; end; @@ -698,165 +642,43 @@ begin else Result := cVFS_Failed; end; -function TVFSEngine.Remove(APath: string): integer; +function TVFSEngine.Remove(const APath: string): integer; begin if @FSourcePlugin.FVFSRemove <> nil then Result := FSourcePlugin.FVFSRemove(FGlobs, PChar(APath)) else Result := cVFS_Failed; end; -function TVFSEngine.RenameFile(SourceFile, DestFile: string): integer; +function TVFSEngine.RenameFile(const SourceFile, DestFile: string): integer; begin if @FSourcePlugin.FVFSRename <> nil then Result := FSourcePlugin.FVFSRename(FGlobs, PChar(SourceFile), PChar(DestFile)) else Result := cVFS_Failed; end; -procedure TVFSEngine.FillDirFiles(APath: string; List: TList; ALevel: word); -var Item: PDataItemSL; - i, Res: integer; - FilesList: TList; - LocalList: TStringList; - P: PVFSItem; - - - procedure AddEntry(FPath: string; AddCurrDirStage, AStage1: boolean); - begin - Item := malloc(SizeOf(TDataItemSL)); - memset(Item, 0, SizeOf(TDataItemSL)); - with Item^ do begin -// AName := malloc(Length(FPath) + 1); -// memset(AName, 0, Length(FPath) + 1); - FName := strdup(PChar(FPath)); - - //* TODO - FDisplayName := StrToUTF8(PChar(FPath)); - if P^.sLinkTo <> nil then LnkPointTo := strdup(P^.sLinkTo) - else LnkPointTo := nil; - ADestination := nil; - Stage1 := AStage1; - IsDir := TVFSItemType(P^.ItemType) = vDirectory; - IsLnk := TVFSItemType(P^.ItemType) = vSymlink; - if IsLnk and AddCurrDirStage then DebugMsg(['*** Assertion failed AddEntry: Item^.IsLnk = True']); - ForceMove := False; -{***} IsOnRO := True; - IsExecutable := AddCurrDirStage or (P^.iMode and S_IXUSR = S_IXUSR); - Mode := P^.iMode; - ModifyTime := P^.m_time; - mtime := P^.m_time; - atime := P^.a_time; - UID := P^.iUID; - GID := P^.iGID; - Size := P^.iSize; - PackedSize := P^.iPackedSize; - Level := ALevel + Ord(not AddCurrDirStage); - end; - if AddCurrDirStage then List.Add(Item) - else FilesList.Add(Item); - end; - -begin - if not Assigned(List) then Exit; - FilesList := TList.Create; - LocalList := TStringList.Create; - try - try - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); - if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); - AddEntry(APath, True, True); - 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); - real_libc_free(P); - - APath := IncludeTrailingPathDelimiter(APath); - if @FSourcePlugin.FVFSChangeDir <> nil then Res := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(APath)) - else Exit; - if Res <> 0 then Exit; - - if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P); - if Res <> cVFS_OK then begin - FSourcePlugin.FVFSListClose(FGlobs); - 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); - real_libc_free(P); - Exit; - end; - - repeat - if TVFSItemType(P^.ItemType) = vDirectory - then LocalList.Add(APath + String(P^.FName)) - else AddEntry(APath + String(P^.FName), False, True); - 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); - real_libc_free(P); - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - Res := FSourcePlugin.FVFSListNext(FGlobs, PChar(GetPath), P); - until (Res <> cVFS_OK); - - 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); - real_libc_free(P); - FSourcePlugin.FVFSListClose(FGlobs); - - if LocalList.Count > 0 then - for i := 0 to LocalList.Count - 1 do - FillDirFiles(LocalList[i], List, ALevel + 1); - - if FilesList.Count > 0 then - for i := 0 to FilesList.Count - 1 do - List.Add(FilesList[i]); - except - on E: Exception do DebugMsg(['*** TVFSEngine.FillDirFiles(APath=', APath, ', Level=', ALevel, ') -Exception: ', E.Message]); - end; - finally - P := real_libc_malloc(SizeOf(TVFSItem)); - memset(P, 0, SizeOf(TVFSItem)); - Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); - if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); - AddEntry(APath, True, False); - 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); - real_libc_free(P); - - LocalList.Free; - FilesList.Free; - end; -end; - function TVFSEngine.MakeSymLink(const NewFileName, PointTo: string): integer; begin if @FSourcePlugin.FVFSMakeSymLink <> nil then Result := FSourcePlugin.FVFSMakeSymLink(FGlobs, PChar(NewFileName), PChar(PointTo)) else Result := cVFS_Failed; end; -function TVFSEngine.Chmod(const FileName: string; const Mode: integer): integer; +function TVFSEngine.Chmod(const FileName: string; Mode: cuLong): integer; begin if @FSourcePlugin.FVFSChmod <> nil then Result := FSourcePlugin.FVFSChmod(FGlobs, PChar(FileName), Mode) else Result := cVFS_Failed; end; -function TVFSEngine.Chown(const FileName: string; const UID, GID: integer): integer; +function TVFSEngine.Chown(const FileName: string; UID, GID: cuLong): integer; begin if @FSourcePlugin.FVFSChown <> nil then Result := FSourcePlugin.FVFSChown(FGlobs, PChar(FileName), UID, GID) else Result := cVFS_Failed; end; -function TVFSEngine.ChangeTimes(APath: string; mtime, atime: Int64): integer; +function TVFSEngine.ChangeTimes(const APath: string; mtime, atime: time_t): integer; begin if @FSourcePlugin.FVFSChangeTimes <> nil then Result := FSourcePlugin.FVFSChangeTimes(FGlobs, PChar(APath), mtime, atime) else Result := cVFS_Failed; end; -function TVFSEngine.GetDirSize(APath: string): Int64; +function TVFSEngine.GetDirSize(const APath: string): Int64; begin if @FSourcePlugin.FVFSGetDirSize <> nil then Result := FSourcePlugin.FVFSGetDirSize(FGlobs, PChar(APath)) else Result := 0; @@ -883,10 +705,11 @@ end; (********************************************************************************************************************************) -function TVFSEngine.IsOnSameFS(const Path1, Path2: string): boolean; +function TVFSEngine.IsOnSameFS(const Path1, Path2: string; FollowSymlinks: boolean): boolean; begin - if @FSourcePlugin.FVFSIsOnSameFS <> nil then Result := FSourcePlugin.FVFSIsOnSameFS(FGlobs, PChar(Path1), PChar(Path2)) - else Result := True; + 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; var Error: integer): TEngineFileDes; @@ -931,26 +754,26 @@ begin end else Result := -1; end; -function TVFSEngine.TwoSameFiles(const Path1, Path2: string): boolean; +function TVFSEngine.TwoSameFiles(const Path1, Path2: string; FollowSymlinks: boolean): boolean; begin - if @FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2)) + if @FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks) else Result := False; end; (********************************************************************************************************************************) -function TVFSEngine.CopyFileIn(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; +function TVFSEngine.CopyFileIn(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; begin Result := CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append, nil, nil, nil, nil); end; -function TVFSEngine.CopyFileOut(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; +function TVFSEngine.CopyFileOut(Sender: Pointer; const SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; begin Result := CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append, nil, nil, nil, nil); end; -function TVFSEngine.CopyFileOutEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; +function TVFSEngine.CopyFileOutEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; var Res: TVFSResult; begin @@ -986,7 +809,7 @@ begin end; end; -function TVFSEngine.CopyFileInEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; +function TVFSEngine.CopyFileInEx(Sender: Pointer; const SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; var Res: TVFSResult; begin diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas index 5da4bc9..75c7349 100644 --- a/vfs/uVFSprototypes.pas +++ b/vfs/uVFSprototypes.pas @@ -27,6 +27,8 @@ unit uVFSprototypes; interface +uses glib2; + {$IFDEF FPC} {$PACKRECORDS C} {$ENDIF} @@ -34,18 +36,6 @@ interface const cVFSVersion = 5; // current version of the VFS API - // Capabilities - capVFS_nil = 0; - capVFS_List = 1; - capVFS_CopyOut = 2; - capVFS_CopyIn = 4; - capVFS_NeedsTemp = 8; // if not set, the seek operation is available - capVFS_Multiple = 16; // support multiple files - ? - capVFS_Execute = 32; - capVFS_Writable = 64; - capVFS_NeedsLogin = 128; // Anonymous is login operation too - - // Error codes (TVFSResult) cVFS_OK = 0; cVFS_Failed = 1; // also No such file @@ -79,70 +69,43 @@ const type TVFSResult = longint; - TVFSGlobs = Pointer; + // Plugin private data for each connection/instance + TVFSGlobs = Pointer; // File descriptor for Open, Read, Write, Close, Seek operations TVFSFileDes = Pointer; TVFSAskPasswordFlags = Longint; + // Let the plugin save password, usually to gnome-keyring PVFSPasswordSave = ^TVFSPasswordSave; - // Let plugin save the password, usually to gnome-keyring TVFSPasswordSave = (VFS_PASSWORD_SAVE_NEVER, VFS_PASSWORD_SAVE_FOR_SESSION, VFS_PASSWORD_SAVE_PERMANENTLY); - TVFSItemType = (vRegular=0, vSymlink=1, vChardev=2, vBlockdev=3, vDirectory=4, vFifo=5, vSock=6, vOther=7); - -{$IFDEF KYLIX} - DWORD = Cardinal; -// ShortBool = boolean; -{$ENDIF} -{$IFNDEF CPU64} - ShortBool = boolean; -{$ENDIF} - - - //* TODO: FName/FDisplayName: napsat presne pravidla pro absolutni/relativni cesty a opravit v modulech i v UVFSCore + TVFSItemType = (vRegular=0, vChardev=1, vBlockdev=2, vDirectory=3, vFifo=4, vSock=5, vOther=6); PVFSItem = ^TVFSItem; TVFSItem = record -{$IFNDEF CPU64} // 32-bit platform FName: PChar; - // FDisplayName - plugins must ensure correct UTF-8 string - FDisplayName: PChar; - iSize: Int64; - // iPackedSize - set to -1 if plugin doesn't support this feature - iPackedSize: Int64; - m_time: DWORD; - a_time: DWORD; - c_time: DWORD; - iMode: Integer; + FDisplayName: PChar; // FDisplayName - plugins must return valid UTF-8 string + iSize: guint64; + iPackedSize: gint64; // iPackedSize - set to -1 if plugin doesn't support this feature + m_time: guint32; + a_time: guint32; + c_time: guint32; + iMode: guint32; + IsLink: gboolean; sLinkTo: PChar; - iUID: Integer; - iGID: Integer; - ItemType: Integer; -{$ELSE} // 64-bit platform - FName: PChar; - FDisplayName: PChar; - iSize: Int64; - iPackedSize: Int64; - m_time: QWORD; - a_time: QWORD; - c_time: QWORD; - iMode: Longint; - __padding1: array[1..4] of byte; - sLinkTo: PChar; - iUID: Longint; - iGID: Longint; - ItemType: Longint; - __padding: array[1..4] of byte; -{$ENDIF} + iUID: guint32; + iGID: guint32; + ItemType: TVFSItemType; end; - // This structure contains basic informations about the plugin + + // Basic information about the plugin PVFSInfo = ^TVFSInfo; TVFSInfo = record ID: PChar; // unique identifier, not shown in GUI @@ -161,10 +124,10 @@ type cancel_choice: Integer; user_data: Pointer); cdecl; - PVFSAskPasswordCallback = ^TVFSAskPasswordCallback; // Remember to allocate passed strings separately (use strdup() when setting reply) // Modules are eligible for keeping passwords during one session; calling callback again means the last password was wrong and user should enter new one // Returns True (1) if succeeded or False (0) if cancelled + PVFSAskPasswordCallback = ^TVFSAskPasswordCallback; TVFSAskPasswordCallback = function (const AMessage: PChar; const default_user: PChar; const default_domain: PChar; @@ -172,104 +135,116 @@ type flags: TVFSAskPasswordFlags; username: PPChar; password: PPChar; - anonymous: PInteger; + anonymous: Pgboolean; domain: PPChar; password_save: PVFSPasswordSave; - user_data: Pointer): LongBool; cdecl; + user_data: Pointer): gboolean; cdecl; // Return False to break the operation PVFSProgressCallback = ^TVFSProgressCallback; - TVFSProgressCallback = function (position: Int64; - max: Int64; - user_data: Pointer): LongBool; cdecl; + TVFSProgressCallback = function (position: guint64; + max: guint64; + user_data: Pointer): gboolean; cdecl; type // Log function for plugin debugging output - host application will print or save these messages + // TODO: add log_level? PVFSLogFunc = ^TVFSLogFunc; TVFSLogFunc = procedure(const S: PChar); cdecl; + // Set callbacks, the user_data value will be passed into them + TVFSSetCallbacks = procedure (g: TVFSGlobs; ask_question_callback: PVFSAskQuestionCallback; + ask_password_callback: PVFSAskPasswordCallback; + progress_func: PVFSProgressCallback; + user_data: Pointer); cdecl; - TVFSNew = function (LogFunc: PVFSLogFunc): TVFSGlobs; cdecl; // Allocates memory for the globs structure and performs intialization of the plugin + TVFSNew = function (LogFunc: PVFSLogFunc): TVFSGlobs; cdecl; + // Performs cleanup and destroys all objects TVFSFree = procedure (g: TVFSGlobs); cdecl; - // Performs cleanup and destroy all objects - TVFSVersion = function: integer; cdecl; - // Returns VFS API Version; must match version hardcoded in the host program, otherwise the module is not loaded + // Returns VFS API Version; must match version hardcoded in the host program, otherwise module is not loaded // Please use the cVFSVersion constant as a return value - TVFSGetInfo = function: PVFSInfo; cdecl; + TVFSVersion = function: integer; cdecl; // Returns module info struct, tuxcmd will take care of memory deallocation - TVFSGetArchiveExts = function: PChar; cdecl; + TVFSGetInfo = function: PVFSInfo; 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 // tuxcmd will take care of memory deallocation - TVFSGetNetworkServices = function: PChar; cdecl; + TVFSGetArchiveExts = function: PChar; cdecl; // Returns the list of supported remote protocols separated by ';' (without the '://') // Returning NULL or not defining the symbol at all means plugin can't access network services // tuxcmd will take care of memory deallocation - TVFSSetProtocolLogFunc = procedure (g:TVFSGlobs; ProtocolLogFunc: TVFSLogFunc); cdecl; + TVFSGetNetworkServices = function: PChar; cdecl; // TODO: Sets the protocol log function (unlike module debug log func this is intended only for server messages (FTP mainly)) - TVFSSetBlockSize = procedure (g:TVFSGlobs; Value: Cardinal); cdecl; - // Sets the block size for I/O operations (not all modules supports this) + TVFSSetProtocolLogFunc = procedure (g:TVFSGlobs; ProtocolLogFunc: TVFSLogFunc); cdecl; + // Sets block size for I/O operations (not supported by all modules) + TVFSSetBlockSize = procedure (g:TVFSGlobs; Value: guint32); cdecl; + // Opens specified archive. This will also switch engine into an archiving mode 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 + // 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 - TVFSClose = function (g:TVFSGlobs): TVFSResult; cdecl; + TVFSOpenURI = function (g:TVFSGlobs; const sURI: PChar): TVFSResult; cdecl; // Closes the file or connection to the server - TVFSMkDir = function (g:TVFSGlobs; const sDirName: PChar): TVFSResult; cdecl; - TVFSRename = function (g:TVFSGlobs; const sSrcName, sDstName: PChar): TVFSResult; cdecl; - // Only rename/move in this function, the two files/directories have to be on the same filesystem - otherway it needs to be copied and deleted manually - TVFSRemove = function (g:TVFSGlobs; const APath: PChar): TVFSResult; cdecl; - // Removes the file/directory (empty only!) - TVFSFileExists = function (g:TVFSGlobs; const FileName: PChar; const Use_lstat: LongBool): LongBool; cdecl; - // This function checks for existing location; the Use_lstat parameter specifies to not follow the symlinks (default false = follow symlinks) - TVFSMakeSymLink = function (g:TVFSGlobs; const NewFileName, PointTo: PChar): TVFSResult; cdecl; - TVFSChmod = function (g:TVFSGlobs; const FileName: PChar; const Mode: integer): TVFSResult; cdecl; - // The parameter for this function is in classic unix format (glibc) - a bit mask - TVFSChown = function (g:TVFSGlobs; const FileName: PChar; const UID, GID: integer): TVFSResult; cdecl; - TVFSChangeTimes = function (g:TVFSGlobs; APath: PChar; mtime, atime: Longint): TVFSResult; cdecl; - // Changes times for the file/directory - mtime and atime are __time_t parameters (glibc) + TVFSClose = function (g:TVFSGlobs): TVFSResult; 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; + // 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; + + + // Try to change directory, checks real access TVFSChangeDir = function (g:TVFSGlobs; const NewPath: PChar): TVFSResult; cdecl; - // Try to change the directory when correct permissions + // Returns current working path, tuxcmd will take care of memory deallocation TVFSGetPath = function (g:TVFSGlobs): PChar; cdecl; - // Returns the current working path (not all plugins can support this; just return '/' in this case) - // tuxcmd will take care of memory deallocation + // Returns the current working path in the URI form, tuxcmd will take care of memory deallocation TVFSGetPathURI = function (g:TVFSGlobs): PChar; cdecl; - // Returns the current working path in the URI form - // tuxcmd will take care of memory deallocation - TVFSGetFileSystemSize = function (g:TVFSGlobs; const APath: PChar): Int64; cdecl; - // Gets the size of filesystem; the path is optional, specified to recognize various mounted filesystems in the tree - TVFSGetFileSystemFree = function (g:TVFSGlobs; const APath: PChar): Int64; cdecl; - TVFSGetFSLabel = function (g:TVFSGlobs; const APath: PChar): PChar; cdecl; - // Gets the filesystem label, tuxcmd will take care of memory deallocation - TVFSIsOnSameFS = function (g:TVFSGlobs; const Path1, Path2: PChar): boolean; cdecl; - TVFSTwoSameFiles = function (g:TVFSGlobs; const Path1, Path2: PChar): boolean; 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; + 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) - TVFSGetDirSize = function (g:TVFSGlobs; APath: PChar): Int64; cdecl; - // Calculates recursively the size of the tree specified under the path APath - TVFSBreakGetDirSize = procedure (g:TVFSGlobs); cdecl; + TVFSTwoSameFiles = function (g:TVFSGlobs; const Path1, Path2: PChar; FollowSymlinks: gboolean): gboolean; cdecl; + // Calculates recursively the size of a tree specified + TVFSGetDirSize = function (g:TVFSGlobs; const APath: PChar): guint64; cdecl; // Call this function to break the calculation performed by VFSGetDirSize - TVFSRun = function (g:TVFSGlobs; const sName: PChar): TVFSResult; cdecl; - // TODO: Runs the command read from inside the archive (typically installing the rpm package) + TVFSBreakGetDirSize = procedure (g:TVFSGlobs); cdecl; + + // Operations + TVFSMkDir = function (g:TVFSGlobs; const sDirName: PChar): TVFSResult; 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; + // Removes file/directory (empty only!) + TVFSRemove = function (g:TVFSGlobs; const APath: PChar): TVFSResult; cdecl; + TVFSMakeSymLink = function (g:TVFSGlobs; const NewFileName, PointTo: PChar): TVFSResult; 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; + // 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; - TVFSCopyToLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: LongBool): TVFSResult; cdecl; - // Performs the copy process from inside of module to the file in the local system + // 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) - // The data pointer is then used to call the callback function in - // 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) + // 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; + // Performs the copy process from local filesystem into the module + TVFSCopyFromLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: gboolean): TVFSResult; cdecl; - TVFSCopyFromLocal = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; Append: LongBool): TVFSResult; cdecl; - // Performs the copy process from the local filesystem into the module - - // Prototype function for packing new files into archive + // TODO: Prototype function for packing new files into archive TVFSPack = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; CompressionLevel: integer; const Password: PChar): TVFSResult; cdecl; - // This is the set of basic functions which can manipulate with the data + // TODO: not implemented at all + // This is the set of basic functions which can manipulate with data // 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) @@ -284,41 +259,14 @@ type // Sets the position in the file from the start and returns real current position - // These are the functions used to list the contents of the directory - // 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): TVFSResult; cdecl; - TVFSListNext = function (g:TVFSGlobs; const sDir: PChar; VFSItem: PVFSItem): TVFSResult; cdecl; - TVFSListClose = function (g:TVFSGlobs): TVFSResult; cdecl; - - //* TODO: napsat presne pravidla pro absolutni/relativni cesty a opravit v modulech i v UVFSCore - TVFSFileInfo = function (g:TVFSGlobs; AFileName: PChar; VFSItem: PVFSItem): TVFSResult; cdecl; - // Gets a single info item without need to list a whole directory - - TVFSGetPasswordRequired = function (g:TVFSGlobs): LongBool; cdecl; - - - // Reset stored session password in the plugin + // Returns flag indicating whether password is required for some files in the archive + TVFSGetPasswordRequired = function (g:TVFSGlobs): gboolean; cdecl; + // Reset stored password in the plugin session TVFSResetPassword = procedure (g: TVFSGlobs); cdecl; - - - /// pridat neco jako set_loglevel ?? - -//// pridat typ pluginu - jestli archive nebo protocol - prip. jeste pridat ktery protokoly je to schopno handlovat - - - - TVFSSetCallbacks = procedure (g: TVFSGlobs; ask_question_callback: PVFSAskQuestionCallback; - ask_password_callback: PVFSAskPasswordCallback; - progress_func: PVFSProgressCallback; - user_data: Pointer); cdecl; - - - // TODO: some function to check the CRC of the archive - it should need also some progress feedback - the processed file and percentage progress -// Prekopat error logging - asi neco na zpusob GError, stringy se budou vracet i z pluginu +// TODO: port error logging subsystem to glib's GError implementation |
