Virtual file system functions on Kodi.  
More...
 | 
|   | File | 
|   | Kodi's file class. 
  | 
|   | 
|   | Stat | 
|   | Get file or file system status. 
  | 
|   | 
 | 
|   | copy (...) | 
|   |  Function:  xbmcvfs.copy(source, destination) 
   Copy file to destination, returns true/false.  
  | 
|   | 
|   | delete (...) | 
|   |  Function:  xbmcvfs.delete(file) 
   Delete a file  
  | 
|   | 
|   | rename (...) | 
|   |  Function:  xbmcvfs.rename(file, newFileName) 
   Rename a file  
  | 
|   | 
|   | exists (...) | 
|   |  Function:  xbmcvfs.exists(path) 
   Check for a file or folder existence  
  | 
|   | 
|   | makeLegalFilename (...) | 
|   |  Function:  xbmcvfs.makeLegalFilename(filename) 
   Returns a legal filename or path as a string.  
  | 
|   | 
|   | translatePath (...) | 
|   |  Function:  xbmcvfs.translatePath(path)  
   Returns the translated path.  
  | 
|   | 
|   | validatePath (...) | 
|   |  Function:  xbmcvfs.validatePath(path) 
   Returns the validated path.  
  | 
|   | 
|   | mkdir (...) | 
|   |  Function:  xbmcvfs.mkdir(path) 
   Create a folder.  
  | 
|   | 
|   | mkdirs (...) | 
|   |  Function:  xbmcvfs.mkdirs(path) 
   Make all directories along the path  
  | 
|   | 
|   | rmdir (...) | 
|   |  Function:  xbmcvfs.rmdir(path, [force]) 
   Remove a folder.  
  | 
|   | 
|   | listdir (...) | 
|   |  Function:  xbmcvfs.listdir(path) 
   Lists content of a folder.  
  | 
|   | 
Virtual file system functions on Kodi. 
Offers classes and functions offers access to the Virtual File Server (VFS) which you can use to manipulate files and folders. 
◆ copy()
 
Function:  xbmcvfs.copy(source, destination) 
  Copy file to destination, returns true/false. 
- Parameters
 - 
  
    | source | file to copy.  | 
    | destination | destination file  | 
  
   
- Returns
 - True if successful
 
Example: 
..
success = xbmcvfs.copy(source, destination)
..
  
 
 
◆ delete()
 
Function:  xbmcvfs.delete(file) 
  Delete a file 
- Parameters
 - 
  
  
 
- Returns
 - True if successful
 
Example: 
..
xbmcvfs.delete(file)
..
  
 
 
◆ exists()
 
Function:  xbmcvfs.exists(path) 
  Check for a file or folder existence 
- Parameters
 - 
  
    | path | File or folder (folder must end with slash or backslash)  | 
  
   
- Returns
 - True if successful
 
Example: 
..
success = xbmcvfs.exists(path)
..
  
 
 
◆ listdir()
 
Function:  xbmcvfs.listdir(path) 
  Lists content of a folder. 
- Parameters
 - 
  
    | path | Folder to get list from  | 
  
   
- Returns
 - Directory content list
 
Example: 
..
dirs, files = xbmcvfs.listdir(path)
..
  
 
 
◆ makeLegalFilename()
 
Function:  xbmcvfs.makeLegalFilename(filename) 
  Returns a legal filename or path as a string. 
- Parameters
 - 
  
    | filename | string - filename/path to make legal  | 
  
   
- Returns
 - Legal filename or path as a string
 
- Note
 - The returned value is platform-specific. This is due to the fact that the chars that need to be replaced to make a path legal depend on the underlying OS filesystem. This is useful, for example, if you want to create a file or folder based on data over which you have no control (e.g. an external API).
 
 - v19 Python API changes
 - New function added (replaces old xbmc.makeLegalFilename)
 
Example: 
..
>> xbmcvfs.makeLegalFilename('C://Trailers/Ice Age: The Meltdown.avi')
C:\Trailers\Ice Age_ The Meltdown.avi
>> xbmcvfs.makeLegalFilename("///\\jk???lj????.mpg")
/jk___lj____.mpg
..
  
 
 
◆ mkdir()
 
Function:  xbmcvfs.mkdir(path) 
  Create a folder. 
- Parameters
 - 
  
  
 
- Returns
 - True if successful
 
Example: 
..
success = xbmcvfs.mkdir(path)
..
  
 
 
◆ mkdirs()
 
Function:  xbmcvfs.mkdirs(path) 
  Make all directories along the path 
Create folder(s) - it will create all folders in the path.
- Parameters
 - 
  
  
 
- Returns
 - True if successful
 
Example: 
..
success = xbmcvfs.mkdirs(path)
..
  
 
 
◆ rename()
 
Function:  xbmcvfs.rename(file, newFileName) 
  Rename a file 
- Parameters
 - 
  
    | file | File to rename  | 
    | newFileName | New filename, including the full path  | 
  
   
- Returns
 - True if successful
 
- Note
 - Moving files between different filesystem (eg. local to nfs://) is not possible on all platforms. You may have to do it manually by using the copy and deleteFile functions.
 
Example: 
..
success = xbmcvfs.rename(file,newFileName)
..
  
 
 
◆ rmdir()
 
Function:  xbmcvfs.rmdir(path, [force]) 
  Remove a folder. 
- Parameters
 - 
  
    | path | string - Folder to remove  | 
    | force | [opt] bool - Force directory removal (default False). This can be useful if the directory is not empty.  | 
  
   
- Returns
 - bool - True if successful, False otherwise
 
Example: 
..
success = xbmcvfs.rmdir(path)
..
  
 
 
◆ translatePath()
 
Function:  xbmcvfs.translatePath(path)  
  Returns the translated path. 
- Parameters
 - 
  
    | path | string - Path to format  | 
  
   
- Returns
 - Translated path
 
- Note
 - Only useful if you are coding for both Linux and Windows. e.g. Converts 'special://home' -> '/home/[username]/.kodi' on Linux.
 
 - v19 Python API changes
 - New function added (replaces old xbmc.translatePath)
 
Example: 
..
fpath = xbmcvfs.translatePath('special://home')
..
  
 
 
◆ validatePath()
 
Function:  xbmcvfs.validatePath(path) 
  Returns the validated path. 
- Parameters
 - 
  
    | path | string - Path to format  | 
  
   
- Returns
 - Validated path
 
- Note
 - The result is platform-specific. Only useful if you are coding for multiple platforms for fixing slash problems (e.g. Corrects 'Z://something' -> 'Z:\something').
 
 - v19 Python API changes
 - New function added (replaces old xbmc.validatePath)
 
Example: 
..
fpath = xbmcvfs.validatePath(somepath)
..