1#ifndef _KVI_FILEUTILS_H_
2#define _KVI_FILEUTILS_H_
44#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
45#define KVI_PATH_SEPARATOR "\\"
46#define KVI_PATH_SEPARATOR_CHAR '\\'
48#define KVI_PATH_SEPARATOR "/"
49#define KVI_PATH_SEPARATOR_CHAR '/'
91 inline bool fileExists(
const QString & szPath) {
return QFile::exists(szPath); }
135 KVILIB_API bool writeFile(
const QString & szPath,
const QByteArray & oData,
bool bAppend =
false);
144 KVILIB_API bool writeFile(
const QString & szPath,
const QString & szData,
bool bAppend =
false);
153 KVILIB_API bool writeFile(
const char * pcPath,
const QString & szData,
bool bAppend =
false);
279 KVILIB_API bool readLines(QFile * pFile, QStringList & buffer,
int iStartLine = 0,
int iCount = -1,
bool bUtf8 =
true);
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124
A namespace to handle file utilities functions.
Definition KviFileUtils.cpp:45
void encodeFileName(QString &szPath)
Translates ANY string into a valid filename (with no path!)
Definition KviFileUtils.cpp:405
bool readFile(const QString &szPath, QString &szBuffer, unsigned int uMaxSize)
Reads a complete file and puts it in the string szBuffer.
Definition KviFileUtils.cpp:288
bool isAbsolutePath(const QString &szPath)
Returns true if the path is absolute, false otherwise.
Definition KviFileUtils.cpp:399
bool writeFileLocal8Bit(const QString &szPath, const QString &szData, bool bAppend)
Writes a complete file (local 8 bit version)
Definition KviFileUtils.cpp:265
bool writeFile(const QString &szPath, const QByteArray &oData, bool bAppend)
Writes a complete file (UTF-8 version)
Definition KviFileUtils.cpp:236
bool readLine(QFile *pFile, QString &szBuffer, bool bUtf8)
Reads a text line, returns false if EOF is reached.
Definition KviFileUtils.cpp:336
bool deleteDir(const QString &szPath)
Removes a dir recursively.
Definition KviFileUtils.cpp:201
QString extractFileName(const QString &szFileNameWithPath, bool bAllowEmpty)
Extracts the filename from a complete path (strips leading path)
Definition KviFileUtils.cpp:321
QString extractFilePath(const QString &szFileNameWithPath)
Extracts the filename from a complete path (strips leading path)
Definition KviFileUtils.cpp:331
bool loadFile(const QString &szPath, QString &szBuffer, bool bUtf8)
Loads the file at szPath to szBuffer eventually converting from UTF-8.
Definition KviFileUtils.cpp:136
void cleanFileName(QString &szPath)
Removes any unusable character from a filename (with no path!)
Definition KviFileUtils.cpp:435
QStringList getFileListing(const QString &szPath)
Definition KviFileUtils.cpp:483
void adjustFilePath(QString &szPath)
Adjusts the file path to the current platform.
Definition KviFileUtils.cpp:154
bool renameFile(const QString &szSrc, const QString &szDst)
Rename or move the file (mv)
Definition KviFileUtils.cpp:88
bool copyFile(const QString &szSrc, const QString &szDst)
Copy the file (cp -f)
Definition KviFileUtils.cpp:101
bool directoryExists(const QString &szPath)
Returns true if szPath points to an existing directory.
Definition KviFileUtils.cpp:381
bool removeFile(const QString &szPath)
Removes a file.
Definition KviFileUtils.cpp:177
bool fileExists(const QString &szPath)
Returns true if szPath points to an existing file.
Definition KviFileUtils.h:91
bool makeDir(const QString &szPath)
Create a directory (mkdir)
Definition KviFileUtils.cpp:48
bool readLines(QFile *pFile, QStringList &buffer, int iStartLine, int iCount, bool bUtf8)
Reads text lines, returns false if EOF is reached.
Definition KviFileUtils.cpp:353
bool removeDir(const QString &szPath)
Removes a dir (must be empty)
Definition KviFileUtils.cpp:189
bool isReadable(const QString &szFname)
Returns true if the file is readable, false otherwise.
Definition KviFileUtils.cpp:387
char szBuffer[4096]
Definition winamp.cpp:77