Kodi Development  20.0
for Binary and Script based Add-Ons
2. File editing functions

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

◆ Open()

virtual kodi::addon::VFSFileHandle 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 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

◆ Close()

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

Close a file.

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

◆ Read()

virtual ssize_t 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

◆ Write()

virtual ssize_t 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

◆ Seek()

virtual int64_t 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 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

◆ GetLength()

virtual int64_t 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 GetPosition ( kodi::addon::VFSFileHandle  context)
inlinevirtual

Get current position in a file.

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

◆ GetChunkSize()

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

Get chunk size of a file.

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

◆ IoControlGetSeekPossible()

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

To check seek possible on current stream by file.

Returns
true if seek possible, false if not

◆ IoControlGetCacheStatus()

virtual bool 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 successfull done, false otherwise

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 unsigned int SetMaxRate GetMaxRate
Average read rate from source file unsigned int SetCurrentRate GetCurrentRate
Cache low speed condition detected bool SetLowspeed GetLowspeed

◆ IoControlSetCacheRate()

virtual bool IoControlSetCacheRate ( kodi::addon::VFSFileHandle  context,
unsigned int  rate 
)
inlinevirtual

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

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

◆ IoControlSetRetry()

virtual bool 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 successfull done, false otherwise