Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
2. File editing functions

File editing functions. More...

Functions

virtual kodi::addon::VFSFileHandle kodi::addon::CInstanceVFS::Open (const kodi::addon::VFSUrl &url)
 Open a file for input.
 
virtual kodi::addon::VFSFileHandle kodi::addon::CInstanceVFS::OpenForWrite (const kodi::addon::VFSUrl &url, bool overWrite)
 Open a file for output.
 
virtual bool kodi::addon::CInstanceVFS::Close (kodi::addon::VFSFileHandle context)
 Close a file.
 
virtual ssize_t kodi::addon::CInstanceVFS::Read (kodi::addon::VFSFileHandle context, uint8_t *buffer, size_t uiBufSize)
 Read from a file.
 
virtual ssize_t kodi::addon::CInstanceVFS::Write (kodi::addon::VFSFileHandle context, const uint8_t *buffer, size_t uiBufSize)
 Write to a file.
 
virtual int64_t kodi::addon::CInstanceVFS::Seek (kodi::addon::VFSFileHandle context, int64_t position, int whence)
 Seek in a file.
 
virtual int kodi::addon::CInstanceVFS::Truncate (kodi::addon::VFSFileHandle context, int64_t size)
 Truncate a file.
 
virtual int64_t kodi::addon::CInstanceVFS::GetLength (kodi::addon::VFSFileHandle context)
 Get total size of a file.
 
virtual int64_t kodi::addon::CInstanceVFS::GetPosition (kodi::addon::VFSFileHandle context)
 Get current position in a file.
 
virtual int kodi::addon::CInstanceVFS::GetChunkSize (kodi::addon::VFSFileHandle context)
 Get chunk size of a file.
 
virtual bool kodi::addon::CInstanceVFS::IoControlGetSeekPossible (kodi::addon::VFSFileHandle context)
 To check seek possible on current stream by file.
 
virtual bool kodi::addon::CInstanceVFS::IoControlGetCacheStatus (kodi::addon::VFSFileHandle context, kodi::vfs::CacheStatus &status)
 To check a running stream on file for state of his cache.
 
virtual bool kodi::addon::CInstanceVFS::IoControlSetCacheRate (kodi::addon::VFSFileHandle context, uint32_t rate)
 Unsigned int with speed limit for caching in bytes per second.
 
virtual bool kodi::addon::CInstanceVFS::IoControlSetRetry (kodi::addon::VFSFileHandle context, bool retry)
 Enable/disable retry within the protocol handler (if supported).
 

Detailed Description

File editing functions.

This value represents the addon-side handlers and to be able to identify his own parts in the event of further access.

Function Documentation

◆ Close()

virtual bool kodi::addon::CInstanceVFS::Close ( kodi::addon::VFSFileHandle context)
inlinevirtual

Close a file.

Parameters
[in]contextThe context of the file
Returns
True on success, false on failure

◆ GetChunkSize()

virtual int kodi::addon::CInstanceVFS::GetChunkSize ( kodi::addon::VFSFileHandle context)
inlinevirtual

Get chunk size of a file.

Parameters
[in]contextThe context of the file
Returns
Chunk size

◆ GetLength()

virtual int64_t kodi::addon::CInstanceVFS::GetLength ( kodi::addon::VFSFileHandle context)
inlinevirtual

Get total size of a file.

Parameters
[in]contextThe context of the file
Returns
Total file size

◆ GetPosition()

virtual int64_t kodi::addon::CInstanceVFS::GetPosition ( kodi::addon::VFSFileHandle context)
inlinevirtual

Get current position in a file.

Parameters
[in]contextThe context of the file
Returns
Current position

◆ IoControlGetCacheStatus()

virtual bool kodi::addon::CInstanceVFS::IoControlGetCacheStatus ( kodi::addon::VFSFileHandle context,
kodi::vfs::CacheStatus & status )
inlinevirtual

To check a running stream on file for state of his cache.

Parameters
[in]statusInformation about current cache status
Returns
true if successfully done, false otherwise

@ingroup cpp_kodi_vfs_Defs_CacheStatus

The following table contains values that can be set with class CacheStatus :

Name Type Set call Get call
Number of bytes cached uint64_t SetForward GetForward
Maximum number of bytes per second uint32_t SetMaxRate GetMaxRate
Average read rate from source file uint32_t SetCurrentRate GetCurrentRate
Cache low speed rate detected uint32_t SetLowRate GetLowRate

◆ IoControlGetSeekPossible()

virtual bool kodi::addon::CInstanceVFS::IoControlGetSeekPossible ( kodi::addon::VFSFileHandle context)
inlinevirtual

To check seek possible on current stream by file.

Returns
true if seek possible, false if not

◆ IoControlSetCacheRate()

virtual bool kodi::addon::CInstanceVFS::IoControlSetCacheRate ( kodi::addon::VFSFileHandle context,
uint32_t rate )
inlinevirtual

Unsigned int with speed limit for caching in bytes per second.

Parameters
[in]rateCache rate size to use
Returns
true if successfully done, false otherwise

◆ IoControlSetRetry()

virtual bool kodi::addon::CInstanceVFS::IoControlSetRetry ( kodi::addon::VFSFileHandle context,
bool retry )
inlinevirtual

Enable/disable retry within the protocol handler (if supported).

Parameters
[in]retryTo set the retry, true for use, false for not
Returns
true if successfully done, false otherwise

◆ Open()

virtual kodi::addon::VFSFileHandle kodi::addon::CInstanceVFS::Open ( const kodi::addon::VFSUrl & url)
inlinevirtual

Open a file for input.

Parameters
[in]urlThe URL of the file
Returns
Context for the opened file

The following table contains values that can be set with class VFSUrl :

Name Type Get call
URL std::string GetURL
Domain name std::string GetDomain
Hostname std::string GetHostname
Filename std::string GetFilename
Network port unsigned int GetPort
Special options std::string GetOptions
Username std::string GetUsername
Password std::string GetPassword
Get URL with user and password hidden std::string GetRedacted
Sharename std::string GetSharename
Network protocol std::string GetProtocol

◆ OpenForWrite()

virtual kodi::addon::VFSFileHandle kodi::addon::CInstanceVFS::OpenForWrite ( const kodi::addon::VFSUrl & url,
bool overWrite )
inlinevirtual

Open a file for output.

Parameters
[in]urlThe URL of the file
[in]overWriteWhether or not to overwrite an existing file
Returns
Context for the opened file

◆ Read()

virtual ssize_t kodi::addon::CInstanceVFS::Read ( kodi::addon::VFSFileHandle context,
uint8_t * buffer,
size_t uiBufSize )
inlinevirtual

Read from a file.

Parameters
[in]contextThe context of the file
[out]bufferThe buffer to read data into
[in]uiBufSizeNumber of bytes to read
Returns
Number of bytes read

◆ Seek()

virtual int64_t kodi::addon::CInstanceVFS::Seek ( kodi::addon::VFSFileHandle context,
int64_t position,
int whence )
inlinevirtual

Seek in a file.

Parameters
[in]contextThe context of the file
[in]positionThe position to seek to
[in]whencePosition in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END):
Value int Description
SEEK_SET 0 position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
SEEK_CUR 1 position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
SEEK_END 2 position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
Returns
Offset in file after seek

◆ Truncate()

virtual int kodi::addon::CInstanceVFS::Truncate ( kodi::addon::VFSFileHandle context,
int64_t size )
inlinevirtual

Truncate a file.

Parameters
[in]contextThe context of the file
[in]sizeThe size to truncate the file to
Returns
0 on success, -1 on error

◆ Write()

virtual ssize_t kodi::addon::CInstanceVFS::Write ( kodi::addon::VFSFileHandle context,
const uint8_t * buffer,
size_t uiBufSize )
inlinevirtual

Write to a file.

Parameters
[in]contextThe context of the file
[in]bufferThe buffer to read data from
[in]uiBufSizeNumber of bytes to write
Returns
Number of bytes written