![]() |
KVIrc
4.9.2
DeveloperAPIs
|
A namespace to handle file utilities functions. More...
Functions | |
| void | adjustFilePath (QString &szPath) |
| Adjusts the file path to the current platform. More... | |
| void | cleanFileName (QString &szPath) |
| Removes any unusable character from a filename (with no path!) More... | |
| bool | copyFile (const QString &szSrc, const QString &szDst) |
| Copy the file (cp -f) More... | |
| bool | copyFile (const char *pcSrc, const char *pcDst) |
| Copy the file (cp -f) More... | |
| bool | deleteDir (const QString &szPath) |
| Removes a dir recursively. More... | |
| bool | directoryExists (const QString &szPath) |
| Returns true if szPath points to an existing directory. More... | |
| void | encodeFileName (QString &szPath) |
| Translates ANY string into a valid filename (with no path!) More... | |
| QString | extractFileName (const QString &szFileNameWithPath, bool bAllowEmpty=true) |
| Extracts the filename from a complete path (strips leading path) More... | |
| QString | extractFilePath (const QString &szFileNameWithPath) |
| Extracts the filename from a complete path (strips leading path) More... | |
| bool | fileExists (const QString &szPath) |
| Returns true if szPath points to an existing file. More... | |
| QStringList | getFileListing (const QString &szPath) |
| static QStringList | getFileListingInternal (const QString &szPath, const QString &szPrefix) |
| bool | isAbsolutePath (const QString &szPath) |
| Returns true if the path is absolute, false otherwise. More... | |
| bool | isReadable (const QString &szFname) |
| Returns true if the file is readable, false otherwise. More... | |
| bool | isReadable (const char *pcPath) |
| bool | loadFile (const QString &szPath, QString &szBuffer, bool bUtf8=true) |
| Loads the file at szPath to szBuffer eventually converting from UTF-8. More... | |
| bool | makeDir (const QString &szPath) |
| Create a directory (mkdir) More... | |
| bool | makeDir (const char *pcPath) |
| Create a directory (mkdir) More... | |
| bool | readFile (const QString &szPath, QString &szBuffer, unsigned int uMaxSize=65535) |
| Reads a complete file and puts it in the string szBuffer. More... | |
| bool | readFile (const char *pcPath, QString &szBuffer, unsigned int uMaxSize=65535) |
| Reads a complete file and puts it in the string szBuffer. More... | |
| bool | readLine (QFile *pFile, QString &szBuffer, bool bUtf8=true) |
| Reads a text line, returns false if EOF is reached. More... | |
| bool | readLines (QFile *pFile, QStringList &buffer, int iStartLine=0, int iCount=-1, bool bUtf8=true) |
| Reads text lines, returns false if EOF is reached. More... | |
| bool | removeDir (const QString &szPath) |
| Removes a dir (must be empty) More... | |
| bool | removeDir (const char *pcPath) |
| Removes a dir (must be empty) More... | |
| bool | removeFile (const QString &szPath) |
| Removes a file. More... | |
| bool | removeFile (const char *pcPath) |
| Removes a file. More... | |
| bool | renameFile (const QString &szSrc, const QString &szDst) |
| Rename or move the file (mv) More... | |
| bool | renameFile (const char *pcSrc, const char *pcDst) |
| Rename or move the file (mv) More... | |
| bool | writeFile (const QString &szPath, const QByteArray &oData, bool bAppend=false) |
| Writes a complete file (UTF-8 version) More... | |
| bool | writeFile (const QString &szPath, const QString &szData, bool bAppend=false) |
| Writes a complete file (UTF-8 version) More... | |
| bool | writeFile (const char *pcPath, const QString &szData, bool bAppend=false) |
| Writes a complete file (UTF-8 version) More... | |
| bool | writeFileLocal8Bit (const QString &szPath, const QString &szData, bool bAppend=false) |
| Writes a complete file (local 8 bit version) More... | |
| bool | writeFileLocal8Bit (const char *pcPath, const QString &szData, bool bAppend=false) |
| Writes a complete file (local 8 bit version) More... | |
Variables | |
| static char | cHexChars [16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' } |
A namespace to handle file utilities functions.
| KVILIB_API void KviFileUtils::adjustFilePath | ( | QString & | szPath | ) |
Adjusts the file path to the current platform.
| szPath | The path to the file |
Referenced by SetupWizard::accept(), addon_kvs_cmd_installfiles(), KviFileDialog::askForDirectoryName(), KviFileDialog::askForOpenFileName(), KviFileDialog::askForSaveFileName(), SetupWizard::chooseDataPath(), SetupWizard::chooseIncomingPath(), SetupWizard::chooseOldDataPath(), DccBroker::chooseSaveFileName(), KviApplication::completeDirectory(), config_kvs_fnc_id(), config_kvs_fnc_open(), LogViewWindow::createLog(), file_kvs_cmd_addimagepath(), file_kvs_cmd_copy(), file_kvs_cmd_delimagepath(), file_kvs_cmd_mkdir(), file_kvs_cmd_remove(), file_kvs_cmd_rename(), file_kvs_cmd_rmdir(), file_kvs_cmd_write(), file_kvs_cmd_writeBytes(), file_kvs_cmd_writeLines(), file_kvs_fnc_allSizes(), file_kvs_fnc_cwd(), file_kvs_fnc_digest(), file_kvs_fnc_exists(), file_kvs_fnc_fixpath(), file_kvs_fnc_globaldir(), file_kvs_fnc_homedir(), file_kvs_fnc_localdir(), file_kvs_fnc_ls(), file_kvs_fnc_read(), file_kvs_fnc_readBytes(), file_kvs_fnc_readLines(), file_kvs_fnc_rootdir(), file_kvs_fnc_size(), file_kvs_fnc_time(), file_kvs_fnc_type(), KviApplication::findGlobalKvircDirectory(), KviApplication::getChannelDumpLogFileName(), KviApplication::getGlobalKvircDirectory(), KviApplication::getLocalKvircDirectory(), RegisteredUsersDialog::importClicked(), KviKvsCoreSimpleCommands::KVSCSC(), makeDir(), SetupWizard::SetupWizard(), theme_kvs_cmd_screenshot(), and KviPackageReader::unpackFile().
| KVILIB_API void KviFileUtils::cleanFileName | ( | QString & | szPath | ) |
Removes any unusable character from a filename (with no path!)
There is NO way to come back to the original string the algo is one-way only
| szPath |
References i.
Referenced by DccBroker::chooseSaveFileName(), and KviWindow::getDefaultLogFileName().
| KVILIB_API bool KviFileUtils::copyFile | ( | const QString & | szSrc, |
| const QString & | szDst | ||
| ) |
Copy the file (cp -f)
| szSrc | The source file |
| szDst | The destination file |
Referenced by addon_kvs_cmd_installfiles(), OptionsWidget_textIcons::chooseFromFile(), copyFile(), LogViewWindow::createLog(), file_kvs_cmd_copy(), and KviTheme::save().
| KVILIB_API bool KviFileUtils::copyFile | ( | const char * | pcSrc, |
| const char * | pcDst | ||
| ) |
Copy the file (cp -f)
| pcSrc | The source file |
| pcDst | The destination file |
References copyFile().
| KVILIB_API bool KviFileUtils::deleteDir | ( | const QString & | szPath | ) |
Removes a dir recursively.
| szPath | The path of the directory to remove |
References d, KviQString::equalCS(), Hidden, removeDir(), and removeFile().
Referenced by ThemeManagementDialog::deleteTheme(), AddonFunctions::installAddonPackage(), and package_kvs_fnc_info().
| KVILIB_API bool KviFileUtils::directoryExists | ( | const QString & | szPath | ) |
Returns true if szPath points to an existing directory.
| szPath | The path to the directory |
References f.
Referenced by SetupWizard::accept(), KviApplication::checkGlobalKvircDirectory(), KviApplication::checkLocalKvircDirectory(), OptionsWidget_textIcons::chooseFromFile(), DccBroker::chooseSaveFileName(), LogViewWindow::createLog(), KviApplication::getGlobalKvircDirectory(), KviApplication::getLocalKvircDirectory(), KviKvsCoreSimpleCommands::KVSCSC(), makeDir(), KviTheme::save(), and KviThemeInfo::setDirectoryAndLocation().
| KVILIB_API void KviFileUtils::encodeFileName | ( | QString & | szPath | ) |
Translates ANY string into a valid filename (with no path!)
There is NO way to come back to the original string the algo is one-way only
| szPath |
Referenced by KviWindow::getDefaultLogFileName().
| KVILIB_API QString KviFileUtils::extractFileName | ( | const QString & | szFileNameWithPath, |
| bool | bAllowEmpty = true |
||
| ) |
Extracts the filename from a complete path (strips leading path)
Extracts the filename from a complete path (strips leading path). If szFileNameWithPath ends with a trailing slash/backslash then if bAllowEmpty is set to true then the name is considered to be empty, if bAllowEmpty is set to false then the trailing slash/backslash is stripped.
| szFileNameWithPath | The complete path to the file |
References KVI_PATH_SEPARATOR.
Referenced by KviConsoleWindow::checkDefaultAvatar(), file_kvs_fnc_extractfilename(), PluginManager::findPlugin(), KviIconManager::getAvatar(), Plugin::load(), KviThemeInfo::setDirectoryAndLocation(), and SetupWizard::SetupWizard().
| KVILIB_API QString KviFileUtils::extractFilePath | ( | const QString & | szFileNameWithPath | ) |
Extracts the filename from a complete path (strips leading path)
| szFileNameWithPath | The complete path |
Referenced by SetupWizard::SetupWizard().
|
inline |
Returns true if szPath points to an existing file.
| szPath | The path to the file |
Referenced by KviFileDialog::askForSaveFileName(), OptionsWidget_textEncoding::commit(), AliasEditorWidget::exportSelectionInSinglesFiles(), ClassEditorWidget::exportSelectionInSinglesFiles(), file_kvs_cmd_copy(), file_kvs_cmd_rename(), KviApplication::findAudioFile(), KviLocale::findCatalogue(), KviApplication::findImage(), KviApplication::findImageInImageSearchPath(), KviApplication::findImageThemeOnlyCompat(), PluginManager::findPlugin(), KviApplication::findSmallIcon(), KviIconManager::getAvatar(), KviApplication::getChannelDumpLogFileName(), KviApplication::getReadOnlyConfigPath(), KviApplication::getTmpFileName(), help_kvs_cmd_open(), RegisteredUsersDialog::importClicked(), KviApplication::KviApplication(), KviLocale::KviLocale(), KviKvsCoreSimpleCommands::KVSCSC(), KVSO_CLASS_FUNCTION(), KviThemeInfo::load(), KviModuleManager::loadModule(), KviKvsObjectController::lookupClass(), KviApplication::mapImageFile(), TipWindow::openConfig(), OptionsWidget_textEncoding::OptionsWidget_textEncoding(), ScriptEditorWidget::ScriptEditorWidget(), KviApplication::setup(), SetupWizard::SetupWizard(), snd_kvs_cmd_play(), and spaste_kvs_cmd_file().
| KVILIB_API QStringList KviFileUtils::getFileListing | ( | const QString & | szPath | ) |
Build a recursive file listing
References getFileListingInternal().
Referenced by package_kvs_fnc_info().
|
static |
References d, and KVI_PATH_SEPARATOR.
Referenced by getFileListing().
| KVILIB_API bool KviFileUtils::isAbsolutePath | ( | const QString & | szPath | ) |
Returns true if the path is absolute, false otherwise.
| szPath | The path to check |
References f.
Referenced by config_kvs_fnc_id(), config_kvs_fnc_open(), KviApplication::findAudioFile(), KviApplication::findImage(), KviMediaManager::findMediaType(), PluginManager::findPlugin(), and KviApplication::mapImageFile().
| KVILIB_API bool KviFileUtils::isReadable | ( | const QString & | szFname | ) |
Returns true if the file is readable, false otherwise.
| szFname | The source file |
References f.
Referenced by KviApplication::checkGlobalKvircDirectory(), isReadable(), and sharedfile_kvs_cmd_add().
| bool KviFileUtils::isReadable | ( | const char * | pcPath | ) |
References isReadable().
| KVILIB_API bool KviFileUtils::loadFile | ( | const QString & | szPath, |
| QString & | szBuffer, | ||
| bool | bUtf8 = true |
||
| ) |
Loads the file at szPath to szBuffer eventually converting from UTF-8.
| szPath | The path to the file to load |
| szBuffer | The buffer where to load the file |
| bUtf8 | Where to convert from UTF-8 |
References f.
Referenced by AboutDialog::AboutDialog(), KviKvsCoreSimpleCommands::KVSCSC(), ScriptEditorImplementation::loadFromFile(), and SetupWizard::SetupWizard().
| KVILIB_API bool KviFileUtils::makeDir | ( | const QString & | szPath | ) |
Create a directory (mkdir)
| szPath | The path to the directory |
References adjustFilePath(), d, directoryExists(), KviQString::getToken(), KVI_PATH_SEPARATOR, KVI_PATH_SEPARATOR_CHAR, and KviQString::stripLeft().
Referenced by SetupWizard::accept(), addon_kvs_cmd_installfiles(), OptionsWidget_textIcons::chooseFromFile(), DccBroker::chooseSaveFileName(), file_kvs_cmd_mkdir(), KviWindow::getDefaultLogFileName(), KviApplication::getLocalKvircDirectory(), makeDir(), KviApplication::notifierMessage(), KviTheme::save(), SaveThemeDialog::saveTheme(), and KviPackageReader::unpackFile().
| KVILIB_API bool KviFileUtils::makeDir | ( | const char * | pcPath | ) |
Create a directory (mkdir)
| pcPath | The path to the directory |
References makeDir().
| KVILIB_API bool KviFileUtils::readFile | ( | const QString & | szPath, |
| QString & | szBuffer, | ||
| unsigned int | uMaxSize = 65535 |
||
| ) |
Reads a complete file and puts it in the string szBuffer.
The file must be smaller than uMaxSize bytes
| szPath | The path to the file to read |
| szBuffer | The buffer where to load the file |
| uMaxSize | The maximum size of the file to read |
References f.
Referenced by KviLocale::KviLocale(), KviKvsObjectClass::load(), readFile(), and KviApplication::setup().
| KVILIB_API bool KviFileUtils::readFile | ( | const char * | pcPath, |
| QString & | szBuffer, | ||
| unsigned int | uMaxSize = 65535 |
||
| ) |
Reads a complete file and puts it in the string szBuffer.
The file must be smaller than uMaxSize bytes
| pcPath | The path to the file to read |
| szBuffer | The buffer where to load the file |
| uMaxSize | The maximum size of the file to read |
References readFile().
| KVILIB_API bool KviFileUtils::readLine | ( | QFile * | pFile, |
| QString & | szBuffer, | ||
| bool | bUtf8 = true |
||
| ) |
Reads a text line, returns false if EOF is reached.
| pFile | The source file |
| szBuffer | The buffer where to store the line read |
| bUtf8 | If we want to convert from UTF-8 |
| KVILIB_API bool KviFileUtils::readLines | ( | QFile * | pFile, |
| QStringList & | buffer, | ||
| int | iStartLine = 0, |
||
| int | iCount = -1, |
||
| bool | bUtf8 = true |
||
| ) |
Reads text lines, returns false if EOF is reached.
| pFile | The source file |
| buffer | The buffer where to store the lines read |
| iStartLine | The number of the first line to read |
| iCount | The number of lines to read |
| bUtf8 | If we want to convert from UTF-8 |
References i.
| KVILIB_API bool KviFileUtils::removeDir | ( | const QString & | szPath | ) |
Removes a dir (must be empty)
| szPath | The directory to remove |
References d.
Referenced by deleteDir(), file_kvs_cmd_rmdir(), and removeDir().
| KVILIB_API bool KviFileUtils::removeDir | ( | const char * | pcPath | ) |
Removes a dir (must be empty)
| pcPath | The directory to remove |
References removeDir().
| KVILIB_API bool KviFileUtils::removeFile | ( | const QString & | szPath | ) |
Removes a file.
| szPath | The file to remove |
References d.
Referenced by OptionsWidget_textEncoding::commit(), KviKvsObjectController::deleteClass(), LogViewWindow::deleteCurrent(), deleteDir(), file_kvs_cmd_remove(), removeFile(), and KviKvsScriptAddonManager::unregisterAddon().
| KVILIB_API bool KviFileUtils::removeFile | ( | const char * | pcPath | ) |
| KVILIB_API bool KviFileUtils::renameFile | ( | const QString & | szSrc, |
| const QString & | szDst | ||
| ) |
Rename or move the file (mv)
| szSrc | The source file |
| szDst | The destination file |
References d.
Referenced by file_kvs_cmd_rename(), and renameFile().
| KVILIB_API bool KviFileUtils::renameFile | ( | const char * | pcSrc, |
| const char * | pcDst | ||
| ) |
Rename or move the file (mv)
| pcSrc | The source file |
| pcDst | The destination file |
References renameFile().
| KVILIB_API bool KviFileUtils::writeFile | ( | const QString & | szPath, |
| const QByteArray & | oData, | ||
| bool | bAppend = false |
||
| ) |
Writes a complete file (UTF-8 version)
| szPath | The path to the file |
| oData | The data to write |
| bAppend | If we want to append data or overwrite |
References f.
Referenced by SetupWizard::accept(), OptionsWidget_textEncoding::commit(), ActionEditor::exportActions(), AliasEditorWidget::exportAliases(), EventEditor::exportAllEvents(), RawEditorWidget::exportAllEvents(), ClassEditorWidget::exportClasses(), EventEditor::exportCurrentHandler(), RawEditorWidget::exportCurrentHandler(), PopupEditorWidget::exportCurrentPopup(), PopupEditorWidget::exportPopups(), AliasEditorWidget::exportSelectionInSinglesFiles(), ClassEditorWidget::exportSelectionInSinglesFiles(), CustomizeToolBarsDialog::exportToolBar(), file_kvs_cmd_write(), SetupWizard::makeLink(), KviApplication::notifierMessage(), package_kvs_cmd_extractField(), KviKvsObjectClass::save(), ScriptEditorImplementation::saveToFile(), SetupWizard::setUrlHandlers(), and writeFile().
| KVILIB_API bool KviFileUtils::writeFile | ( | const QString & | szPath, |
| const QString & | szData, | ||
| bool | bAppend = false |
||
| ) |
Writes a complete file (UTF-8 version)
| szPath | The path to the file |
| szData | The data to write |
| bAppend | If we want to append data or overwrite |
References f.
| KVILIB_API bool KviFileUtils::writeFile | ( | const char * | pcPath, |
| const QString & | szData, | ||
| bool | bAppend = false |
||
| ) |
Writes a complete file (UTF-8 version)
| pcPath | The path to the file |
| szData | The data to write |
| bAppend | If we want to append data or overwrite |
References writeFile().
| KVILIB_API bool KviFileUtils::writeFileLocal8Bit | ( | const QString & | szPath, |
| const QString & | szData, | ||
| bool | bAppend = false |
||
| ) |
Writes a complete file (local 8 bit version)
| szPath | The path to the file |
| szData | The data to write |
| bAppend | If we want to append data or overwrite |
References f.
Referenced by file_kvs_cmd_write(), and writeFileLocal8Bit().
| KVILIB_API bool KviFileUtils::writeFileLocal8Bit | ( | const char * | pcPath, |
| const QString & | szData, | ||
| bool | bAppend = false |
||
| ) |
Writes a complete file (local 8 bit version)
| pcPath | The path to the file |
| szData | The data to write |
| bAppend | If we want to append data or overwrite |
References writeFileLocal8Bit().
|
static |
Referenced by encodeFileName().
1.8.7