Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
URIUtils Class Reference

#include <URIUtils.h>

Static Public Member Functions

static void RegisterAdvancedSettings (const CAdvancedSettings &advancedSettings)
 
static void UnregisterAdvancedSettings ()
 
static std::string GetDirectory (const std::string &strFilePath)
 
static std::string GetFileName (const CURL &url)
 
static std::string GetFileName (const std::string &strFileNameAndPath)
 
static std::string GetFileOrFolderName (const std::string &path)
 
static std::string GetExtension (const CURL &url)
 
static std::string GetExtension (const std::string &strFileName)
 
static bool HasPluginPath (const CFileItem &item)
 Check if the CFileItem has a plugin path.
 
static bool HasExtension (const std::string &strFileName)
 Check if there is a file extension.
 
static bool HasExtension (const std::string &strFileName, const std::string &strExtensions)
 Check if filename have any of the listed extensions.
 
static bool HasExtension (const CURL &url, const std::string &strExtensions)
 
static void RemoveExtension (std::string &strFileName)
 
static std::string ReplaceExtension (const std::string &strFile, const std::string &strNewExtension)
 
static void Split (const std::string &strFileNameAndPath, std::string &strPath, std::string &strFileName)
 
static std::vector< std::string > SplitPath (const std::string &strPath)
 
static void GetCommonPath (std::string &strParent, const std::string &strPath)
 
static std::string GetParentPath (const std::string &strPath)
 
static bool GetParentPath (const std::string &strPath, std::string &strParent)
 
static std::string GetBasePath (const std::string &strPath)
 Retrieve the base path, accounting for stacks and files in rars.
 
static std::string ChangeBasePath (const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath=true)
 
static CURL SubstitutePath (const CURL &url, bool reverse=false)
 
static std::string SubstitutePath (const std::string &strPath, bool reverse=false)
 
static bool IsProtocol (const std::string &url, const std::string &type)
 Check whether a URL is a given URL scheme. Comparison is case-insensitive as per RFC1738.
 
static bool PathHasParent (std::string path, std::string parent, bool translate=false)
 Check whether a path has a given parent. Comparison is case-sensitive. Use IsProtocol() to compare the protocol portion only.
 
static bool PathEquals (std::string path1, std::string path2, bool ignoreTrailingSlash=false, bool ignoreURLOptions=false)
 Check whether a path equals another path. Comparison is case-sensitive.
 
static bool IsAddonsPath (const std::string &strFile)
 
static bool IsSourcesPath (const std::string &strFile)
 
static bool IsCDDA (const std::string &strFile)
 
static bool IsDAV (const std::string &strFile)
 
static bool IsDOSPath (const std::string &path)
 
static bool IsDVD (const std::string &strFile)
 
static bool IsFTP (const std::string &strFile)
 
static bool IsHTTP (const std::string &strFile, bool bTranslate=false)
 
static bool IsUDP (const std::string &strFile)
 
static bool IsTCP (const std::string &strFile)
 
static bool IsHD (const std::string &strFileName)
 
static bool IsInArchive (const std::string &strFile)
 
static bool IsInRAR (const std::string &strFile)
 
static bool IsInternetStream (const std::string &path, bool bStrictCheck=false)
 
static bool IsInternetStream (const CURL &url, bool bStrictCheck=false)
 
static bool IsStreamedFilesystem (const std::string &strPath)
 
static bool IsNetworkFilesystem (const std::string &strPath)
 
static bool IsInAPK (const std::string &strFile)
 
static bool IsInZIP (const std::string &strFile)
 
static bool IsISO9660 (const std::string &strFile)
 
static bool IsLiveTV (const std::string &strFile)
 
static bool IsPVRRecording (const std::string &strFile)
 
static bool IsPVRRecordingFileOrFolder (const std::string &strFile)
 
static bool IsPVRTVRecordingFileOrFolder (const std::string &strFile)
 
static bool IsPVRRadioRecordingFileOrFolder (const std::string &strFile)
 
static bool IsMultiPath (const std::string &strPath)
 
static bool IsMusicDb (const std::string &strFile)
 
static bool IsNfs (const std::string &strFile)
 
static bool IsOnDVD (const std::string &strFile)
 
static bool IsOnLAN (const std::string &strFile, LanCheckMode lanCheckMode=LanCheckMode::ONLY_LOCAL_SUBNET)
 
static bool IsHostOnLAN (const std::string &hostName, LanCheckMode lanCheckMode=LanCheckMode::ONLY_LOCAL_SUBNET)
 
static bool IsPlugin (const std::string &strFile)
 
static bool IsScript (const std::string &strFile)
 
static bool IsRAR (const std::string &strFile)
 
static bool IsRemote (const std::string &strFile)
 
static bool IsSmb (const std::string &strFile)
 
static bool IsSpecial (const std::string &strFile)
 
static bool IsStack (const std::string &strFile)
 
static bool IsFavourite (const std::string &strFile)
 
static bool IsUPnP (const std::string &strFile)
 
static bool IsURL (const std::string &strFile)
 
static bool IsVideoDb (const std::string &strFile)
 
static bool IsAPK (const std::string &strFile)
 
static bool IsZIP (const std::string &strFile)
 
static bool IsArchive (const std::string &strFile)
 
static bool IsDiscImage (const std::string &file)
 
static bool IsDiscImageStack (const std::string &file)
 
static bool IsBluray (const std::string &strFile)
 
static bool IsAndroidApp (const std::string &strFile)
 
static bool IsLibraryFolder (const std::string &strFile)
 
static bool IsLibraryContent (const std::string &strFile)
 
static bool IsPVR (const std::string &strFile)
 
static bool IsPVRChannel (const std::string &strFile)
 
static bool IsPVRRadioChannel (const std::string &strFile)
 
static bool IsPVRChannelGroup (const std::string &strFile)
 
static bool IsPVRGuideItem (const std::string &strFile)
 
static std::string AppendSlash (std::string strFolder)
 
static void AddSlashAtEnd (std::string &strFolder)
 
static bool HasSlashAtEnd (const std::string &strFile, bool checkURL=false)
 
static void RemoveSlashAtEnd (std::string &strFolder)
 
static bool CompareWithoutSlashAtEnd (const std::string &strPath1, const std::string &strPath2)
 
static std::string FixSlashesAndDups (const std::string &path, const char slashCharacter='/', const size_t startFrom=0)
 
static std::string CanonicalizePath (const std::string &path, const char slashCharacter='\\')
 
static CURL CreateArchivePath (const std::string &type, const CURL &archiveUrl, const std::string &pathInArchive="", const std::string &password="")
 
static std::string AddFileToFolder (const std::string &strFolder, const std::string &strFile)
 
template<typename... T>
static std::string AddFileToFolder (const std::string &strFolder, const std::string &strFile, T... args)
 
static bool HasParentInHostname (const CURL &url)
 
static bool HasEncodedHostname (const CURL &url)
 
static bool HasEncodedFilename (const CURL &url)
 
static std::string GetRealPath (const std::string &path)
 Cleans up the given path by resolving "." and ".." and returns it.
 
static bool UpdateUrlEncoding (std::string &strFilename)
 Updates the URL encoded hostname of the given path.
 

Member Function Documentation

◆ AddFileToFolder() [1/2]

std::string URIUtils::AddFileToFolder ( const std::string & strFolder,
const std::string & strFile )
static

◆ AddFileToFolder() [2/2]

template<typename... T>
static std::string URIUtils::AddFileToFolder ( const std::string & strFolder,
const std::string & strFile,
T... args )
inlinestatic

◆ AddSlashAtEnd()

void URIUtils::AddSlashAtEnd ( std::string & strFolder)
static

◆ AppendSlash()

std::string URIUtils::AppendSlash ( std::string strFolder)
static

◆ CanonicalizePath()

std::string URIUtils::CanonicalizePath ( const std::string & path,
const char slashCharacter = '\\' )
static

Convert path to form without duplicated slashes and without relative directories Strip duplicated slashes Resolve and remove relative directories ("/../" and "/./") Will ignore slashes with other direction than specified Will not resolve path starting from relative directory

Warning
Don't use with "protocol://path"-style URLs
Parameters
pathstring to process
slashCharactercharacter to use as directory delimiter
Returns
transformed path

◆ ChangeBasePath()

std::string URIUtils::ChangeBasePath ( const std::string & fromPath,
const std::string & fromFile,
const std::string & toPath,
const bool & bAddPath = true )
static

◆ CompareWithoutSlashAtEnd()

bool URIUtils::CompareWithoutSlashAtEnd ( const std::string & strPath1,
const std::string & strPath2 )
static

◆ CreateArchivePath()

CURL URIUtils::CreateArchivePath ( const std::string & type,
const CURL & archiveUrl,
const std::string & pathInArchive = "",
const std::string & password = "" )
static

◆ FixSlashesAndDups()

std::string URIUtils::FixSlashesAndDups ( const std::string & path,
const char slashCharacter = '/',
const size_t startFrom = 0 )
static

◆ GetBasePath()

std::string URIUtils::GetBasePath ( const std::string & strPath)
static

Retrieve the base path, accounting for stacks and files in rars.

Parameters
strPathpath.
Returns
the folder that contains the item.

◆ GetCommonPath()

void URIUtils::GetCommonPath ( std::string & strParent,
const std::string & strPath )
static

◆ GetDirectory()

std::string URIUtils::GetDirectory ( const std::string & strFilePath)
static

◆ GetExtension() [1/2]

std::string URIUtils::GetExtension ( const CURL & url)
static

◆ GetExtension() [2/2]

std::string URIUtils::GetExtension ( const std::string & strFileName)
static

◆ GetFileName() [1/2]

std::string URIUtils::GetFileName ( const CURL & url)
static

◆ GetFileName() [2/2]

std::string URIUtils::GetFileName ( const std::string & strFileNameAndPath)
static

◆ GetFileOrFolderName()

std::string URIUtils::GetFileOrFolderName ( const std::string & path)
static

◆ GetParentPath() [1/2]

std::string URIUtils::GetParentPath ( const std::string & strPath)
static

◆ GetParentPath() [2/2]

bool URIUtils::GetParentPath ( const std::string & strPath,
std::string & strParent )
static
Todo
Make a new python call to get the plugin content type and remove this temporary hack

◆ GetRealPath()

std::string URIUtils::GetRealPath ( const std::string & path)
static

Cleans up the given path by resolving "." and ".." and returns it.

This methods goes through the given path and removes any "." (as it states "this directory") and resolves any ".." by removing the previous directory from the path. This is done for file paths and host names (in case of VFS paths).

Parameters
pathPath to be cleaned up
Returns
Actual path without any "." or ".."

◆ HasEncodedFilename()

bool URIUtils::HasEncodedFilename ( const CURL & url)
static

◆ HasEncodedHostname()

bool URIUtils::HasEncodedHostname ( const CURL & url)
static

◆ HasExtension() [1/3]

bool URIUtils::HasExtension ( const CURL & url,
const std::string & strExtensions )
static

◆ HasExtension() [2/3]

bool URIUtils::HasExtension ( const std::string & strFileName)
static

Check if there is a file extension.

Parameters
strFileNamePath or URL to check
Returns
true if strFileName have an extension.
Note
Returns false when strFileName is empty.
See also
GetExtension

◆ HasExtension() [3/3]

bool URIUtils::HasExtension ( const std::string & strFileName,
const std::string & strExtensions )
static

Check if filename have any of the listed extensions.

Parameters
strFileNamePath or URL to check
strExtensionsList of '.' prefixed lowercase extensions separated with '|'
Returns
true if strFileName have any one of the extensions.
Note
The check is case insensitive for strFileName, but requires strExtensions to be lowercase. Returns false when strFileName or strExtensions is empty.
See also
GetExtension

◆ HasParentInHostname()

bool URIUtils::HasParentInHostname ( const CURL & url)
static

◆ HasPluginPath()

bool URIUtils::HasPluginPath ( const CFileItem & item)
static

Check if the CFileItem has a plugin path.

Parameters
itemThe CFileItem.
Returns
true if there is a plugin path, false otherwise.

◆ HasSlashAtEnd()

bool URIUtils::HasSlashAtEnd ( const std::string & strFile,
bool checkURL = false )
static

◆ IsAddonsPath()

bool URIUtils::IsAddonsPath ( const std::string & strFile)
static

◆ IsAndroidApp()

bool URIUtils::IsAndroidApp ( const std::string & strFile)
static

◆ IsAPK()

bool URIUtils::IsAPK ( const std::string & strFile)
static

◆ IsArchive()

bool URIUtils::IsArchive ( const std::string & strFile)
static

◆ IsBluray()

bool URIUtils::IsBluray ( const std::string & strFile)
static

◆ IsCDDA()

bool URIUtils::IsCDDA ( const std::string & strFile)
static

◆ IsDAV()

bool URIUtils::IsDAV ( const std::string & strFile)
static

◆ IsDiscImage()

bool URIUtils::IsDiscImage ( const std::string & file)
static

◆ IsDiscImageStack()

bool URIUtils::IsDiscImageStack ( const std::string & file)
static

◆ IsDOSPath()

bool URIUtils::IsDOSPath ( const std::string & path)
static

◆ IsDVD()

bool URIUtils::IsDVD ( const std::string & strFile)
static

◆ IsFavourite()

bool URIUtils::IsFavourite ( const std::string & strFile)
static

◆ IsFTP()

bool URIUtils::IsFTP ( const std::string & strFile)
static

◆ IsHD()

bool URIUtils::IsHD ( const std::string & strFileName)
static

◆ IsHostOnLAN()

bool URIUtils::IsHostOnLAN ( const std::string & hostName,
LanCheckMode lanCheckMode = LanCheckMode::ONLY_LOCAL_SUBNET )
static

◆ IsHTTP()

bool URIUtils::IsHTTP ( const std::string & strFile,
bool bTranslate = false )
static

◆ IsInAPK()

bool URIUtils::IsInAPK ( const std::string & strFile)
static

◆ IsInArchive()

bool URIUtils::IsInArchive ( const std::string & strFile)
static

◆ IsInRAR()

bool URIUtils::IsInRAR ( const std::string & strFile)
static

◆ IsInternetStream() [1/2]

bool URIUtils::IsInternetStream ( const CURL & url,
bool bStrictCheck = false )
static

◆ IsInternetStream() [2/2]

bool URIUtils::IsInternetStream ( const std::string & path,
bool bStrictCheck = false )
static

◆ IsInZIP()

bool URIUtils::IsInZIP ( const std::string & strFile)
static

◆ IsISO9660()

bool URIUtils::IsISO9660 ( const std::string & strFile)
static

◆ IsLibraryContent()

bool URIUtils::IsLibraryContent ( const std::string & strFile)
static

◆ IsLibraryFolder()

bool URIUtils::IsLibraryFolder ( const std::string & strFile)
static

◆ IsLiveTV()

bool URIUtils::IsLiveTV ( const std::string & strFile)
static

◆ IsMultiPath()

bool URIUtils::IsMultiPath ( const std::string & strPath)
static

◆ IsMusicDb()

bool URIUtils::IsMusicDb ( const std::string & strFile)
static

◆ IsNetworkFilesystem()

bool URIUtils::IsNetworkFilesystem ( const std::string & strPath)
static

◆ IsNfs()

bool URIUtils::IsNfs ( const std::string & strFile)
static

◆ IsOnDVD()

bool URIUtils::IsOnDVD ( const std::string & strFile)
static

◆ IsOnLAN()

bool URIUtils::IsOnLAN ( const std::string & strFile,
LanCheckMode lanCheckMode = LanCheckMode::ONLY_LOCAL_SUBNET )
static

◆ IsPlugin()

bool URIUtils::IsPlugin ( const std::string & strFile)
static

◆ IsProtocol()

bool URIUtils::IsProtocol ( const std::string & url,
const std::string & type )
static

Check whether a URL is a given URL scheme. Comparison is case-insensitive as per RFC1738.

Parameters
urla std::string path.
typea lower-case scheme name, e.g. "smb".
Returns
true if the url is of the given scheme, false otherwise.
See also
PathHasParent, PathEquals

◆ IsPVR()

bool URIUtils::IsPVR ( const std::string & strFile)
static

◆ IsPVRChannel()

bool URIUtils::IsPVRChannel ( const std::string & strFile)
static

◆ IsPVRChannelGroup()

bool URIUtils::IsPVRChannelGroup ( const std::string & strFile)
static

◆ IsPVRGuideItem()

bool URIUtils::IsPVRGuideItem ( const std::string & strFile)
static

◆ IsPVRRadioChannel()

bool URIUtils::IsPVRRadioChannel ( const std::string & strFile)
static

◆ IsPVRRadioRecordingFileOrFolder()

bool URIUtils::IsPVRRadioRecordingFileOrFolder ( const std::string & strFile)
static

◆ IsPVRRecording()

bool URIUtils::IsPVRRecording ( const std::string & strFile)
static

◆ IsPVRRecordingFileOrFolder()

bool URIUtils::IsPVRRecordingFileOrFolder ( const std::string & strFile)
static

◆ IsPVRTVRecordingFileOrFolder()

bool URIUtils::IsPVRTVRecordingFileOrFolder ( const std::string & strFile)
static

◆ IsRAR()

bool URIUtils::IsRAR ( const std::string & strFile)
static

◆ IsRemote()

bool URIUtils::IsRemote ( const std::string & strFile)
static

◆ IsScript()

bool URIUtils::IsScript ( const std::string & strFile)
static

◆ IsSmb()

bool URIUtils::IsSmb ( const std::string & strFile)
static

◆ IsSourcesPath()

bool URIUtils::IsSourcesPath ( const std::string & strFile)
static

◆ IsSpecial()

bool URIUtils::IsSpecial ( const std::string & strFile)
static

◆ IsStack()

bool URIUtils::IsStack ( const std::string & strFile)
static

◆ IsStreamedFilesystem()

bool URIUtils::IsStreamedFilesystem ( const std::string & strPath)
static
Todo
sftp/ssh special case has to be handled by vfs addon

◆ IsTCP()

bool URIUtils::IsTCP ( const std::string & strFile)
static

◆ IsUDP()

bool URIUtils::IsUDP ( const std::string & strFile)
static

◆ IsUPnP()

bool URIUtils::IsUPnP ( const std::string & strFile)
static

◆ IsURL()

bool URIUtils::IsURL ( const std::string & strFile)
static

◆ IsVideoDb()

bool URIUtils::IsVideoDb ( const std::string & strFile)
static

◆ IsZIP()

bool URIUtils::IsZIP ( const std::string & strFile)
static

◆ PathEquals()

bool URIUtils::PathEquals ( std::string path1,
std::string path2,
bool ignoreTrailingSlash = false,
bool ignoreURLOptions = false )
static

Check whether a path equals another path. Comparison is case-sensitive.

Parameters
path1a std::string path.
path2the second path the path should be compared against.
ignoreTrailingSlashignore any trailing slashes in both paths
Returns
true if the paths are equal, false otherwise.
See also
IsProtocol, PathHasParent

◆ PathHasParent()

bool URIUtils::PathHasParent ( std::string path,
std::string parent,
bool translate = false )
static

Check whether a path has a given parent. Comparison is case-sensitive. Use IsProtocol() to compare the protocol portion only.

Parameters
patha std::string path.
parentthe string the parent of the path should be compared against.
translatewhether to translate any special paths into real paths
Returns
true if the path has the given parent string, false otherwise.
See also
IsProtocol, PathEquals

◆ RegisterAdvancedSettings()

void URIUtils::RegisterAdvancedSettings ( const CAdvancedSettings & advancedSettings)
static

◆ RemoveExtension()

void URIUtils::RemoveExtension ( std::string & strFileName)
static

◆ RemoveSlashAtEnd()

void URIUtils::RemoveSlashAtEnd ( std::string & strFolder)
static

◆ ReplaceExtension()

std::string URIUtils::ReplaceExtension ( const std::string & strFile,
const std::string & strNewExtension )
static

◆ Split()

void URIUtils::Split ( const std::string & strFileNameAndPath,
std::string & strPath,
std::string & strFileName )
static

◆ SplitPath()

std::vector< std::string > URIUtils::SplitPath ( const std::string & strPath)
static

◆ SubstitutePath() [1/2]

CURL URIUtils::SubstitutePath ( const CURL & url,
bool reverse = false )
static

◆ SubstitutePath() [2/2]

std::string URIUtils::SubstitutePath ( const std::string & strPath,
bool reverse = false )
static

◆ UnregisterAdvancedSettings()

void URIUtils::UnregisterAdvancedSettings ( )
static

◆ UpdateUrlEncoding()

bool URIUtils::UpdateUrlEncoding ( std::string & strFilename)
static

Updates the URL encoded hostname of the given path.

This method must only be used to update paths encoded with the old (Eden) URL encoding implementation to the new (Frodo) URL encoding implementation (which does not URL encode -_.!().

Parameters
strFilenamePath to update
Returns
True if the path has been updated/changed otherwise false

The documentation for this class was generated from the following files: