summaryrefslogtreecommitdiff
path: root/vfs/uVFSprototypes.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-10-25 11:32:12 +0200
committerTomas Bzatek <tbzatek@redhat.com>2024-10-25 11:32:12 +0200
commitd08636bdad4f36431bfdf07e8400d7188a2df781 (patch)
tree841aef1904f9c87ee02e1a730ef488cc75215ec6 /vfs/uVFSprototypes.pas
parent741e1499ed55e20c136298ced705dcbb59915117 (diff)
downloadtuxcmd-d08636bdad4f36431bfdf07e8400d7188a2df781.tar.xz
Rework file copy/open-read-write-close data handlingv0.6.83
Stick to the POSIX open(2), read(2), write(2), close(2) return values semantics, apply on the VFS interface. Also handle short reads and writes that are common for some gvfs backends. This makes cross-VFS copy work.
Diffstat (limited to 'vfs/uVFSprototypes.pas')
-rw-r--r--vfs/uVFSprototypes.pas19
1 files changed, 9 insertions, 10 deletions
diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas
index 9ed0844..6fbe65d 100644
--- a/vfs/uVFSprototypes.pas
+++ b/vfs/uVFSprototypes.pas
@@ -224,7 +224,7 @@ type
// Changes times for the file/directory - mtime and atime are __time_t parameters (glibc)
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 -
@@ -242,20 +242,19 @@ type
TVFSPack = function (g:TVFSGlobs; const sSrcName, sDstName: PChar; CompressionLevel: integer; const Password: PChar; Error: PPGError): gboolean; cdecl;
- // 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
+ // Low-level open-read-write-close, used for e.g. cross-VFS copy
+ // An abstract TVFSFileDes object serves as a file descriptor/handle
// 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: 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: 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: PPGError): integer; cdecl;
- // Returns number of bytes written
+ TVFSReadFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; ABlockSize: guint64; Error: PPGError): gint64; cdecl;
+ // Returns number of bytes read that may be smaller than requested number of bytes. Returns 0 typically at EOF or -1 in case of an error.
+ // The buffer needs to be allocated for a blocksize (set it by VFSSetBlockSize function)
+ TVFSWriteFile = function (g:TVFSGlobs; const FileDescriptor: TVFSFileDes; Buffer: Pointer; BytesCount: guint64; Error: PPGError): gint64; cdecl;
+ // Returns number of bytes written that may be smaller than requested number of bytes. Returns -1 in case of an error.
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
+ // Sets the position in the file from the start and returns real current position. Returns -1 in case of an error.
// Archive-specific routines: