Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.

Kodi's file class. More...

Classes

class  XBMCAddon::xbmcvfs::File
 

Functions

 XBMCAddon::xbmcvfs::File::File (const String &filepath, const char *mode=NULL)
 
 XBMCAddon::xbmcvfs::File::~File () override
 
 XBMCAddon::xbmcvfs::File::read (...)
 
 XBMCAddon::xbmcvfs::File::readBytes (...)
 
 XBMCAddon::xbmcvfs::File::write (...)
 
 XBMCAddon::xbmcvfs::File::size ()
 
 XBMCAddon::xbmcvfs::File::seek (...)
 
 XBMCAddon::xbmcvfs::File::close ()
 
const XFILE::CFileXBMCAddon::xbmcvfs::File::getFile () const
 

Detailed Description

Kodi's file class.

Class: xbmcvfs.File(filepath, [mode])

Parameters
filepathstring Selected file path
mode[opt] string Additional mode options (if no mode is supplied, the default is Open for Read).
Mode Description
w Open for write

Example:

..
f = xbmcvfs.File(file, 'w')
..

Function Documentation

◆ close()

XBMCAddon::xbmcvfs::File::close ( )

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> close() </big></font></span></code></h4> \endhtmlonly

Close opened file.


Example:

..
f = xbmcvfs.File(file)
f.close()
..

◆ File()

XBMCAddon::xbmcvfs::File::File ( const String filepath,
const char *  mode = NULL 
)
inline

◆ getFile()

const XFILE::CFile * XBMCAddon::xbmcvfs::File::getFile ( ) const
inline

◆ read()

XBMCAddon::xbmcvfs::File::read (   ...)

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> read([bytes]) </big></font></span></code></h4> \endhtmlonly

Read file parts as string.

Parameters
bytes[opt] How many bytes to read - if not set it will read the whole file
Returns
string

Example:

..
f = xbmcvfs.File(file)
b = f.read()
f.close()
..

◆ readBytes()

XbmcCommons::Buffer XBMCAddon::xbmcvfs::File::readBytes (   ...)

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> readBytes(numbytes) </big></font></span></code></h4> \endhtmlonly

Read bytes from file.

Parameters
numbytesHow many bytes to read [opt]- if not set it will read the whole file
Returns
bytearray

Example:

..
f = xbmcvfs.File(file)
b = f.read()
f.close()
..

◆ seek()

XBMCAddon::xbmcvfs::File::seek (   ...)

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> seek(seekBytes, iWhence) </big></font></span></code></h4> \endhtmlonly

Seek to position in file.

Parameters
seekBytesposition in the file
iWhencewhere in a file to seek from[0 beginning, 1 current , 2 end position]

Example:

..
f = xbmcvfs.File(file)
result = f.seek(8129, 0)
f.close()
..

◆ size()

XBMCAddon::xbmcvfs::File::size ( )

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> size() </big></font></span></code></h4> \endhtmlonly

Get the file size.

Returns
The file size

Example:

..
f = xbmcvfs.File(file)
s = f.size()
f.close()
..

◆ write()

bool XBMCAddon::xbmcvfs::File::write (   ...)

@brief \htmlonly <h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font color=31363b><big> write(buffer) </big></font></span></code></h4> \endhtmlonly

To write given data in file.

Parameters
bufferBuffer to write to file
Returns
True on success.

Example:

..
f = xbmcvfs.File(file, 'w')
result = f.write(buffer)
f.close()
..

◆ ~File()

XBMCAddon::xbmcvfs::File::~File ( )
inlineoverride