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

#include <Util.h>

Static Public Member Functions

static void CleanString (const std::string &strFileName, std::string &strTitle, std::string &strTitleAndYear, std::string &strYear, bool bRemoveExtension=false, bool bCleanChars=true)
 
static std::string GetTitleFromPath (const CURL &url, bool bIsFolder=false)
 
static std::string GetTitleFromPath (const std::string &strFileNameAndPath, bool bIsFolder=false)
 
static void GetQualifiedFilename (const std::string &strBasePath, std::string &strFilename)
 
static void RunShortcut (const char *szPath)
 
static std::string GetHomePath (std::string strTarget="KODI_HOME")
 
static bool IsPVR (const std::string &strFile)
 
static bool IsHTSP (const std::string &strFile)
 
static bool IsLiveTV (const std::string &strFile)
 
static bool IsTVRecording (const std::string &strFile)
 
static bool ExcludeFileOrFolder (const std::string &strFileOrFolder, const std::vector< std::string > &regexps)
 
static void GetFileAndProtocol (const std::string &strURL, std::string &strDir)
 
static int GetDVDIfoTitle (const std::string &strPathFile)
 
static bool IsPicture (const std::string &strFile)
 
static std::string GetSplashPath ()
 Get resolved filesystem location of splash image. More...
 
static std::string GetFileDigest (const std::string &strPath, KODI::UTILITY::CDigest::Type type)
 retrieve MD5sum of a file More...
 
static bool GetDirectoryName (const std::string &strFileName, std::string &strDescription)
 
static void GetDVDDriveIcon (const std::string &strPath, std::string &strIcon)
 
static void RemoveTempFiles ()
 
static void ClearTempFonts ()
 
static void ClearSubtitles ()
 
static void ScanForExternalSubtitles (const std::string &strMovie, std::vector< std::string > &vecSubtitles)
 
static ExternalStreamInfo GetExternalStreamDetailsFromFilename (const std::string &videoPath, const std::string &associatedFile)
 Retrieves stream info of external associated files, e.g., subtitles, for a given video. More...
 
static bool FindVobSubPair (const std::vector< std::string > &vecSubtitles, const std::string &strIdxPath, std::string &strSubPath)
 in a vector of subtitles finds the corresponding .sub file for a given .idx file More...
 
static bool IsVobSub (const std::vector< std::string > &vecSubtitles, const std::string &strSubPath)
 checks if in the vector of subtitles the given .sub file has a corresponding idx and hence is a vobsub file More...
 
static std::string GetVobSubSubFromIdx (const std::string &vobSubIdx)
 find a plain or archived vobsub .sub file corresponding to an .idx file More...
 
static std::string GetVobSubIdxFromSub (const std::string &vobSub)
 find a .idx file from a path of a plain or archived vobsub .sub file More...
 
static void ScanForExternalAudio (const std::string &videoPath, std::vector< std::string > &vecAudio)
 Retrieves paths of external audio files for a given video. More...
 
static void ScanForExternalDemuxSub (const std::string &videoPath, std::vector< std::string > &vecSubtitles)
 
static int64_t ToInt64 (uint32_t high, uint32_t low)
 
static std::string GetNextFilename (const std::string &fn_template, int max)
 
static std::string GetNextPathname (const std::string &path_template, int max)
 
static void StatToStatI64 (struct _stati64 *result, struct stat *stat)
 
static void StatToStat64 (struct __stat64 *result, const struct stat *stat)
 
static void Stat64ToStatI64 (struct _stati64 *result, struct __stat64 *stat)
 
static void StatI64ToStat64 (struct __stat64 *result, struct _stati64 *stat)
 
static void Stat64ToStat (struct stat *result, struct __stat64 *stat)
 
static bool CreateDirectoryEx (const std::string &strPath)
 
static std::string MakeLegalFileName (const std::string &strFile, int LegalType=LEGAL_NONE)
 
static std::string MakeLegalPath (const std::string &strPath, int LegalType=LEGAL_NONE)
 
static std::string ValidatePath (const std::string &path, bool bFixDoubleSlashes=false)
 return a validated path, with correct directory separators. More...
 
static bool IsUsingTTFSubtitles ()
 
static void SplitParams (const std::string &paramString, std::vector< std::string > &parameters)
 Split a comma separated parameter list into separate parameters. Takes care of the case where we may have a quoted string containing commas, or we may have a function (i.e. parentheses) with multiple parameters as a single parameter. More...
 
static void SplitExecFunction (const std::string &execString, std::string &function, std::vector< std::string > &parameters)
 
static int GetMatchingSource (const std::string &strPath, VECSOURCES &VECSOURCES, bool &bIsSourceName)
 
static std::string TranslateSpecialSource (const std::string &strSpecial)
 
static void DeleteDirectoryCache (const std::string &prefix="")
 
static void DeleteMusicDatabaseDirectoryCache ()
 
static void DeleteVideoDatabaseDirectoryCache ()
 
static std::string MusicPlaylistsLocation ()
 
static std::string VideoPlaylistsLocation ()
 
static void GetSkinThemes (std::vector< std::string > &vecTheme)
 
static void GetRecursiveListing (const std::string &strPath, CFileItemList &items, const std::string &strMask, unsigned int flags=0)
 
static void GetRecursiveDirsListing (const std::string &strPath, CFileItemList &items, unsigned int flags=0)
 
static void ForceForwardSlashes (std::string &strPath)
 
static double AlbumRelevance (const std::string &strAlbumTemp1, const std::string &strAlbum1, const std::string &strArtistTemp1, const std::string &strArtist1)
 
static bool MakeShortenPath (std::string StrInput, std::string &StrOutput, size_t iTextMaxLength)
 
static bool SupportsWriteFileOperations (const std::string &strPath)
 Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...) More...
 
static bool SupportsReadFileOperations (const std::string &strPath)
 Checks wether the supplied path supports Read file operations (e.g. Copy, ...) More...
 
static std::string GetDefaultFolderThumb (const std::string &folderThumb)
 
static void InitRandomSeed ()
 
static int LookupRomanDigit (char roman_digit)
 
static int TranslateRomanNumeral (const char *roman_numeral)
 
static std::string ResolveExecutablePath ()
 
static std::string GetFrameworksPath (bool forPython=false)
 
static bool CanBindPrivileged ()
 
static bool ValidatePort (int port)
 
static int GetRandomNumber ()
 Thread-safe random number generation. More...
 
static int64_t ConvertSecsToMilliSecs (double secs)
 
static double ConvertMilliSecsToSecs (int64_t offset)
 
static int64_t ConvertMilliSecsToSecsInt (int64_t offset)
 
static int64_t ConvertMilliSecsToSecsIntRounded (int64_t offset)
 

Static Protected Member Functions

static void GetVideoBasePathAndFileName (const std::string &videoPath, std::string &basePath, std::string &videoFileName)
 Retrieves the base path and the filename of a given video. More...
 
static void GetItemsToScan (const std::string &videoPath, const std::string &item_exts, const std::vector< std::string > &sub_dirs, CFileItemList &items)
 Retrieves FileItems that could contain associated files of a given video. More...
 
static void ScanPathsForAssociatedItems (const std::string &videoName, const CFileItemList &items, const std::vector< std::string > &item_exts, std::vector< std::string > &associatedFiles)
 Searches for associated files of a given video. More...
 
static int ScanArchiveForAssociatedItems (const std::string &strArchivePath, const std::string &videoNameNoExt, const std::vector< std::string > &item_exts, std::vector< std::string > &associatedFiles)
 Searches in an archive for associated files of a given video. More...
 

Member Function Documentation

◆ AlbumRelevance()

double CUtil::AlbumRelevance ( const std::string &  strAlbumTemp1,
const std::string &  strAlbum1,
const std::string &  strArtistTemp1,
const std::string &  strArtist1 
)
static

◆ CanBindPrivileged()

bool CUtil::CanBindPrivileged ( )
static

◆ CleanString()

void CUtil::CleanString ( const std::string &  strFileName,
std::string &  strTitle,
std::string &  strTitleAndYear,
std::string &  strYear,
bool  bRemoveExtension = false,
bool  bCleanChars = true 
)
static

◆ ClearSubtitles()

void CUtil::ClearSubtitles ( )
static

◆ ClearTempFonts()

void CUtil::ClearTempFonts ( )
static

◆ ConvertMilliSecsToSecs()

static double CUtil::ConvertMilliSecsToSecs ( int64_t  offset)
inlinestatic

◆ ConvertMilliSecsToSecsInt()

static int64_t CUtil::ConvertMilliSecsToSecsInt ( int64_t  offset)
inlinestatic

◆ ConvertMilliSecsToSecsIntRounded()

static int64_t CUtil::ConvertMilliSecsToSecsIntRounded ( int64_t  offset)
inlinestatic

◆ ConvertSecsToMilliSecs()

static int64_t CUtil::ConvertSecsToMilliSecs ( double  secs)
inlinestatic

◆ CreateDirectoryEx()

bool CUtil::CreateDirectoryEx ( const std::string &  strPath)
static

◆ DeleteDirectoryCache()

void CUtil::DeleteDirectoryCache ( const std::string &  prefix = "")
static

◆ DeleteMusicDatabaseDirectoryCache()

void CUtil::DeleteMusicDatabaseDirectoryCache ( )
static

◆ DeleteVideoDatabaseDirectoryCache()

void CUtil::DeleteVideoDatabaseDirectoryCache ( )
static

◆ ExcludeFileOrFolder()

bool CUtil::ExcludeFileOrFolder ( const std::string &  strFileOrFolder,
const std::vector< std::string > &  regexps 
)
static

◆ FindVobSubPair()

bool CUtil::FindVobSubPair ( const std::vector< std::string > &  vecSubtitles,
const std::string &  strIdxPath,
std::string &  strSubPath 
)
static

in a vector of subtitles finds the corresponding .sub file for a given .idx file

◆ ForceForwardSlashes()

void CUtil::ForceForwardSlashes ( std::string &  strPath)
static

◆ GetDefaultFolderThumb()

std::string CUtil::GetDefaultFolderThumb ( const std::string &  folderThumb)
static

◆ GetDirectoryName()

bool CUtil::GetDirectoryName ( const std::string &  strFileName,
std::string &  strDescription 
)
static

◆ GetDVDDriveIcon()

void CUtil::GetDVDDriveIcon ( const std::string &  strPath,
std::string &  strIcon 
)
static

◆ GetDVDIfoTitle()

int CUtil::GetDVDIfoTitle ( const std::string &  strPathFile)
static

◆ GetExternalStreamDetailsFromFilename()

ExternalStreamInfo CUtil::GetExternalStreamDetailsFromFilename ( const std::string &  videoPath,
const std::string &  associatedFile 
)
static

Retrieves stream info of external associated files, e.g., subtitles, for a given video.

Parameters
[in]videoPathThe full path of the video file.
[in]associatedFileA file that provides additional streams for the given video file.
Returns
stream info for the given associatedFile

◆ GetFileAndProtocol()

void CUtil::GetFileAndProtocol ( const std::string &  strURL,
std::string &  strDir 
)
static

◆ GetFileDigest()

std::string CUtil::GetFileDigest ( const std::string &  strPath,
KODI::UTILITY::CDigest::Type  type 
)
static

retrieve MD5sum of a file

Parameters
strPath- path to the file to MD5sum
Returns
md5 sum of the file

◆ GetFrameworksPath()

std::string CUtil::GetFrameworksPath ( bool  forPython = false)
static

◆ GetHomePath()

std::string CUtil::GetHomePath ( std::string  strTarget = "KODI_HOME")
static

◆ GetItemsToScan()

void CUtil::GetItemsToScan ( const std::string &  videoPath,
const std::string &  item_exts,
const std::vector< std::string > &  sub_dirs,
CFileItemList items 
)
staticprotected

Retrieves FileItems that could contain associated files of a given video.

Parameters
[in]videoPathThe full path of the video file.
[in]item_extsA | separated string of extensions specifying the associated files.
[in]sub_dirsA vector of sub directory names to look for.
[out]itemsA List of FileItems to scan for associated files.

◆ GetMatchingSource()

int CUtil::GetMatchingSource ( const std::string &  strPath,
VECSOURCES VECSOURCES,
bool &  bIsSourceName 
)
static

◆ GetNextFilename()

std::string CUtil::GetNextFilename ( const std::string &  fn_template,
int  max 
)
static

◆ GetNextPathname()

std::string CUtil::GetNextPathname ( const std::string &  path_template,
int  max 
)
static

◆ GetQualifiedFilename()

void CUtil::GetQualifiedFilename ( const std::string &  strBasePath,
std::string &  strFilename 
)
static

◆ GetRandomNumber()

int CUtil::GetRandomNumber ( )
static

Thread-safe random number generation.

◆ GetRecursiveDirsListing()

void CUtil::GetRecursiveDirsListing ( const std::string &  strPath,
CFileItemList items,
unsigned int  flags = 0 
)
static

◆ GetRecursiveListing()

void CUtil::GetRecursiveListing ( const std::string &  strPath,
CFileItemList items,
const std::string &  strMask,
unsigned int  flags = 0 
)
static

◆ GetSkinThemes()

void CUtil::GetSkinThemes ( std::vector< std::string > &  vecTheme)
static

◆ GetSplashPath()

std::string CUtil::GetSplashPath ( )
static

Get resolved filesystem location of splash image.

◆ GetTitleFromPath() [1/2]

std::string CUtil::GetTitleFromPath ( const CURL url,
bool  bIsFolder = false 
)
static

◆ GetTitleFromPath() [2/2]

std::string CUtil::GetTitleFromPath ( const std::string &  strFileNameAndPath,
bool  bIsFolder = false 
)
static

◆ GetVideoBasePathAndFileName()

void CUtil::GetVideoBasePathAndFileName ( const std::string &  videoPath,
std::string &  basePath,
std::string &  videoFileName 
)
staticprotected

Retrieves the base path and the filename of a given video.

Parameters
[in]videoPathThe full path of the video file.
[out]basePathThe base path of the given video.
[out]videoFileNameThe file name of the given video..

◆ GetVobSubIdxFromSub()

std::string CUtil::GetVobSubIdxFromSub ( const std::string &  vobSub)
static

find a .idx file from a path of a plain or archived vobsub .sub file

◆ GetVobSubSubFromIdx()

std::string CUtil::GetVobSubSubFromIdx ( const std::string &  vobSubIdx)
static

find a plain or archived vobsub .sub file corresponding to an .idx file

◆ InitRandomSeed()

void CUtil::InitRandomSeed ( )
static

◆ IsHTSP()

static bool CUtil::IsHTSP ( const std::string &  strFile)
static

◆ IsLiveTV()

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

◆ IsPicture()

bool CUtil::IsPicture ( const std::string &  strFile)
static

◆ IsPVR()

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

◆ IsTVRecording()

bool CUtil::IsTVRecording ( const std::string &  strFile)
static

◆ IsUsingTTFSubtitles()

bool CUtil::IsUsingTTFSubtitles ( )
static

◆ IsVobSub()

bool CUtil::IsVobSub ( const std::vector< std::string > &  vecSubtitles,
const std::string &  strSubPath 
)
static

checks if in the vector of subtitles the given .sub file has a corresponding idx and hence is a vobsub file

◆ LookupRomanDigit()

int CUtil::LookupRomanDigit ( char  roman_digit)
static

◆ MakeLegalFileName()

std::string CUtil::MakeLegalFileName ( const std::string &  strFile,
int  LegalType = LEGAL_NONE 
)
static

◆ MakeLegalPath()

std::string CUtil::MakeLegalPath ( const std::string &  strPath,
int  LegalType = LEGAL_NONE 
)
static

◆ MakeShortenPath()

bool CUtil::MakeShortenPath ( std::string  StrInput,
std::string &  StrOutput,
size_t  iTextMaxLength 
)
static

◆ MusicPlaylistsLocation()

std::string CUtil::MusicPlaylistsLocation ( )
static

◆ RemoveTempFiles()

void CUtil::RemoveTempFiles ( )
static

◆ ResolveExecutablePath()

std::string CUtil::ResolveExecutablePath ( )
static

◆ RunShortcut()

void CUtil::RunShortcut ( const char *  szPath)
static

◆ ScanArchiveForAssociatedItems()

int CUtil::ScanArchiveForAssociatedItems ( const std::string &  strArchivePath,
const std::string &  videoNameNoExt,
const std::vector< std::string > &  item_exts,
std::vector< std::string > &  associatedFiles 
)
staticprotected

Searches in an archive for associated files of a given video.

Parameters
[in]strArchivePathThe full path of the archive.
[in]videoNameNoExtThe filename of the video without extension for which associated files should be retrieved.
[in]item_extsA vector of extensions specifying the associated files.
[out]associatedFilesA vector containing the full paths of all found associated files.

◆ ScanForExternalAudio()

void CUtil::ScanForExternalAudio ( const std::string &  videoPath,
std::vector< std::string > &  vecAudio 
)
static

Retrieves paths of external audio files for a given video.

Parameters
[in]videoPathThe full path of the video file.
[out]vecAudioA vector containing the full paths of all found external audio files.

◆ ScanForExternalDemuxSub()

void CUtil::ScanForExternalDemuxSub ( const std::string &  videoPath,
std::vector< std::string > &  vecSubtitles 
)
static

◆ ScanForExternalSubtitles()

void CUtil::ScanForExternalSubtitles ( const std::string &  strMovie,
std::vector< std::string > &  vecSubtitles 
)
static

◆ ScanPathsForAssociatedItems()

void CUtil::ScanPathsForAssociatedItems ( const std::string &  videoName,
const CFileItemList items,
const std::vector< std::string > &  item_exts,
std::vector< std::string > &  associatedFiles 
)
staticprotected

Searches for associated files of a given video.

Parameters
[in]videoNameThe name of the video file.
[in]itemsA List of FileItems to scan for associated files.
[in]item_extsA vector of extensions specifying the associated files.
[out]associatedFilesA vector containing the full paths of all found associated files.

◆ SplitExecFunction()

void CUtil::SplitExecFunction ( const std::string &  execString,
std::string &  function,
std::vector< std::string > &  parameters 
)
static

◆ SplitParams()

void CUtil::SplitParams ( const std::string &  paramString,
std::vector< std::string > &  parameters 
)
static

Split a comma separated parameter list into separate parameters. Takes care of the case where we may have a quoted string containing commas, or we may have a function (i.e. parentheses) with multiple parameters as a single parameter.

eg:

foo, bar(param1, param2), foo

will return:

"foo", "bar(param1, param2)", and "foo".

Parameters
paramStringthe string to break up
parametersthe returned parameters

◆ Stat64ToStat()

void CUtil::Stat64ToStat ( struct stat *  result,
struct __stat64 stat 
)
static

◆ Stat64ToStatI64()

void CUtil::Stat64ToStatI64 ( struct _stati64 result,
struct __stat64 stat 
)
static

◆ StatI64ToStat64()

void CUtil::StatI64ToStat64 ( struct __stat64 result,
struct _stati64 stat 
)
static

◆ StatToStat64()

void CUtil::StatToStat64 ( struct __stat64 result,
const struct stat *  stat 
)
static

◆ StatToStatI64()

void CUtil::StatToStatI64 ( struct _stati64 result,
struct stat *  stat 
)
static

◆ SupportsReadFileOperations()

bool CUtil::SupportsReadFileOperations ( const std::string &  strPath)
static

Checks wether the supplied path supports Read file operations (e.g. Copy, ...)

Parameters
strPaththe path to be checked
Returns
true if Read file operations are supported, false otherwise

◆ SupportsWriteFileOperations()

bool CUtil::SupportsWriteFileOperations ( const std::string &  strPath)
static

Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...)

Parameters
strPaththe path to be checked
Returns
true if Write file operations are supported, false otherwise

◆ ToInt64()

int64_t CUtil::ToInt64 ( uint32_t  high,
uint32_t  low 
)
static

◆ TranslateRomanNumeral()

int CUtil::TranslateRomanNumeral ( const char *  roman_numeral)
static

◆ TranslateSpecialSource()

std::string CUtil::TranslateSpecialSource ( const std::string &  strSpecial)
static

◆ ValidatePath()

std::string CUtil::ValidatePath ( const std::string &  path,
bool  bFixDoubleSlashes = false 
)
static

return a validated path, with correct directory separators.

◆ ValidatePort()

bool CUtil::ValidatePort ( int  port)
static

◆ VideoPlaylistsLocation()

std::string CUtil::VideoPlaylistsLocation ( )
static

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