Sayonara Player
Functions
Helper::File Namespace Reference

Detailed Description

Filehelper functions.

Functions

QString clean_filename (const QString &filename)
 formatter for filepaths. Removes double separators and replaces them with os specific separators. More...
 
QString calc_file_extension (const QString &filename)
 calc_file_extension More...
 
void remove_files_in_directory (const QString &dir_name, const QStringList &filters=QStringList())
 Remove all files from directory. More...
 
void delete_files (const QStringList &files)
 Remove all given files (also directories can be specified) More...
 
QString get_parent_directory (const QString &path)
 get parent directory of a filepath More...
 
QString get_filename_of_path (const QString &path)
 extract pure filename from a complete file path More...
 
void split_filename (const QString &src, QString &dir, QString &filename)
 split filename into the dir and filename More...
 
QString get_file_extension (const QString &filename)
 get file extension More...
 
QStringList get_parent_directories (const QStringList &list)
 extract parent folder of a file list (see also get_parent_directory(const QString& path) More...
 
QString get_absolute_filename (const QString &filename)
 get absolute filename of file More...
 
bool create_directories (const QString &path)
 create all directories necessary to access path More...
 
QString calc_filesize_str (quint64 filesize)
 convert filesize to string More...
 
bool is_absolute (const QString &filename)
 Tell whether filename is absolute. More...
 
bool write_file (const QByteArray &raw_data, const QString &filename)
 Write raw data to file. More...
 
bool read_file_into_str (const QString &filename, QString &content)
 read a complete file into a string More...
 
bool read_file_into_byte_arr (const QString &filename, QByteArray &content)
 read a complete file into a byte array More...
 
bool check_file (const QString &filepath)
 Check, if file is valid. Web URLs are always valid. More...
 
bool is_url (const QString &str)
 
bool is_www (const QString &str)
 
bool is_file (const QString &filename)
 
bool is_dir (const QString &filename)
 
bool is_soundfile (const QString &filename)
 
bool is_playlistfile (const QString &filename)
 
bool is_podcastfile (const QString &filename, const QByteArray &content)
 

Function Documentation

◆ calc_file_extension()

QString Helper::File::calc_file_extension ( const QString &  filename)

calc_file_extension

Parameters
filename
Returns

◆ calc_filesize_str()

QString Helper::File::calc_filesize_str ( quint64  filesize)

convert filesize to string

Parameters
filesizein bytes
Returns
converted string

◆ check_file()

bool Helper::File::check_file ( const QString &  filepath)

Check, if file is valid. Web URLs are always valid.

Parameters
filepathpath to file or resource
Returns
true, if file exists or if Web URL. false else

◆ clean_filename()

QString Helper::File::clean_filename ( const QString &  filename)

formatter for filepaths. Removes double separators and replaces them with os specific separators.

Parameters
filenameinput filename
Returns
nicely formatted filename

◆ create_directories()

bool Helper::File::create_directories ( const QString &  path)

create all directories necessary to access path

Parameters
pathfull target path

◆ delete_files()

void Helper::File::delete_files ( const QStringList &  files)

Remove all given files (also directories can be specified)

Parameters
fileslist of files

◆ get_absolute_filename()

QString Helper::File::get_absolute_filename ( const QString &  filename)

get absolute filename of file

Parameters
filename
Returns

◆ get_file_extension()

QString Helper::File::get_file_extension ( const QString &  filename)

get file extension

Parameters
filenamefilename to get the extension for
Returns
extension string

◆ get_filename_of_path()

QString Helper::File::get_filename_of_path ( const QString &  path)

extract pure filename from a complete file path

Parameters
pathcomplete file path
Returns
pure filename

◆ get_parent_directories()

QStringList Helper::File::get_parent_directories ( const QStringList &  list)

extract parent folder of a file list (see also get_parent_directory(const QString& path)

Parameters
listfile list
Returns
List of parent folders

◆ get_parent_directory()

QString Helper::File::get_parent_directory ( const QString &  path)

get parent directory of a filepath

Parameters
pathFile- or directory path
Returns

◆ is_absolute()

bool Helper::File::is_absolute ( const QString &  filename)

Tell whether filename is absolute.

Parameters
filenamethe filename to check
Returns
true if filename is absolute, false else

◆ read_file_into_byte_arr()

bool Helper::File::read_file_into_byte_arr ( const QString &  filename,
QByteArray &  content 
)

read a complete file into a byte array

Parameters
filenamefilename
contenttarget reference to content
Returns
true if file could be read, false else

◆ read_file_into_str()

bool Helper::File::read_file_into_str ( const QString &  filename,
QString &  content 
)

read a complete file into a string

Parameters
filenamefilename
contenttarget reference to content
Returns
true if file could be read, false else

◆ remove_files_in_directory()

void Helper::File::remove_files_in_directory ( const QString &  dir_name,
const QStringList &  filters = QStringList() 
)

Remove all files from directory.

Parameters
dir_namedirectory name
filtersfile name filters

◆ split_filename()

void Helper::File::split_filename ( const QString &  src,
QString &  dir,
QString &  filename 
)

split filename into the dir and filename

Parameters
src
path
filename

◆ write_file()

bool Helper::File::write_file ( const QByteArray &  raw_data,
const QString &  filename 
)

Write raw data to file.

Parameters
raw_dataraw data
filenametarget_filename
Returns
true if successful, false else