mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Changed: Added more comments
This commit is contained in:
parent
1d70d9c21a
commit
32e71c4b97
2 changed files with 30 additions and 4 deletions
|
@ -81,6 +81,7 @@ bool isDirectoryEmpty(const QString &directory, bool recursize)
|
||||||
|
|
||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
{
|
{
|
||||||
|
// process all files and directories excepted parent and current ones
|
||||||
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
@ -89,10 +90,12 @@ bool isDirectoryEmpty(const QString &directory, bool recursize)
|
||||||
|
|
||||||
if (fileInfo.isDir())
|
if (fileInfo.isDir())
|
||||||
{
|
{
|
||||||
|
// don't consider empty directories as files, but process it recursively if required
|
||||||
if (recursize) if (!isDirectoryEmpty(fileInfo.absoluteFilePath(), true)) return false;
|
if (recursize) if (!isDirectoryEmpty(fileInfo.absoluteFilePath(), true)) return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// we found a file, directory is not empty
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,6 +130,7 @@ qint64 getDirectorySize(const QString &directory, bool recursize)
|
||||||
|
|
||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
{
|
{
|
||||||
|
// process all files and directories excepted parent and current ones
|
||||||
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
|
|
@ -28,40 +28,62 @@
|
||||||
* \date 2016
|
* \date 2016
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// convert a size in bytes to a QString with larger unit (KiB, MiB, etc...)
|
||||||
QString qBytesToHumanReadable(qint64 bytes);
|
QString qBytesToHumanReadable(qint64 bytes);
|
||||||
QString nameToId(const QString &name);
|
QString nameToId(const QString &name);
|
||||||
|
|
||||||
|
// return true is the specified directory is empty (has no file inside) (and all its subdirectories if recursize is true)
|
||||||
bool isDirectoryEmpty(const QString &directory, bool recursize);
|
bool isDirectoryEmpty(const QString &directory, bool recursize);
|
||||||
|
|
||||||
|
// check if specified directory is writable
|
||||||
bool isDirectoryWritable(const QString &directory);
|
bool isDirectoryWritable(const QString &directory);
|
||||||
|
|
||||||
|
// return the total size in bytes of specified directtory (and all its subdirectories if recursize is true)
|
||||||
qint64 getDirectorySize(const QString &directory, bool recursize);
|
qint64 getDirectorySize(const QString &directory, bool recursize);
|
||||||
|
|
||||||
// Convert a UTF-8 string to QString
|
// convert a UTF-8 string to QString
|
||||||
QString qFromUtf8(const std::string &str);
|
QString qFromUtf8(const std::string &str);
|
||||||
|
|
||||||
// Convert a QString to UTF-8 string
|
// convert a QString to UTF-8 string
|
||||||
std::string qToUtf8(const QString &str);
|
std::string qToUtf8(const QString &str);
|
||||||
|
|
||||||
// Convert a UTF-16 string to QString
|
// convert an UTF-16 string to QString
|
||||||
QString qFromUtf16(const ucstring &str);
|
QString qFromUtf16(const ucstring &str);
|
||||||
|
|
||||||
// Convert a QString to UTF-16 string
|
// convert a QString to UTF-16 string
|
||||||
ucstring qToUtf16(const QString &str);
|
ucstring qToUtf16(const QString &str);
|
||||||
|
|
||||||
|
// convert an wchar_t* to QString
|
||||||
QString qFromWide(const wchar_t *str);
|
QString qFromWide(const wchar_t *str);
|
||||||
|
|
||||||
|
// convert an QString to wchar_t*
|
||||||
wchar_t* qToWide(const QString &str);
|
wchar_t* qToWide(const QString &str);
|
||||||
|
|
||||||
|
// check if a shortcut already exists (the extension will be added)
|
||||||
bool shortcutExists(const QString &shortcut);
|
bool shortcutExists(const QString &shortcut);
|
||||||
|
|
||||||
|
// create a shortcut with the native format of the current platform
|
||||||
bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
|
bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
|
||||||
|
|
||||||
|
// remove a shortcut (the extension will be added)
|
||||||
bool removeShortcut(const QString &shortcut);
|
bool removeShortcut(const QString &shortcut);
|
||||||
|
|
||||||
|
// return the real path of shortcut
|
||||||
bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pathObj);
|
bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pathObj);
|
||||||
|
|
||||||
|
// append the shortcut of current platform to specified path
|
||||||
QString appendShortcutExtension(const QString &shortcut);
|
QString appendShortcutExtension(const QString &shortcut);
|
||||||
|
|
||||||
|
// launch an executable with --version parameter and parse version string
|
||||||
QString getVersionFromExecutable(const QString &path);
|
QString getVersionFromExecutable(const QString &path);
|
||||||
|
|
||||||
|
// write a resource in QRC to disk
|
||||||
bool writeResource(const QString &resource, const QString &path);
|
bool writeResource(const QString &resource, const QString &path);
|
||||||
|
|
||||||
|
// write a resource in QRC to disk and replace all variables by specified values
|
||||||
bool writeResourceWithTemplates(const QString &resource, const QString &path, const QMap<QString, QString> &strings);
|
bool writeResourceWithTemplates(const QString &resource, const QString &path, const QMap<QString, QString> &strings);
|
||||||
|
|
||||||
|
// a little helper class to unintialize COM after using it
|
||||||
class CCOMHelper
|
class CCOMHelper
|
||||||
{
|
{
|
||||||
bool m_mustUninit;
|
bool m_mustUninit;
|
||||||
|
|
Loading…
Reference in a new issue