1 #ifndef _KVI_FILEUTILS_H_
2 #define _KVI_FILEUTILS_H_
40 #include <QStringList>
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 '/'
58 namespace KviFileUtils
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);
182 KVILIB_API bool readFile(
const QString & szPath, QString & szBuffer,
unsigned int uMaxSize = 65535);
193 KVILIB_API bool readFile(
const char * pcPath, QString & szBuffer,
unsigned int uMaxSize = 65535);
279 KVILIB_API bool readLines(QFile * pFile, QStringList & buffer,
int iStartLine = 0,
int iCount = -1,
bool bUtf8 =
true);
321 #endif //_KVI_FILEUTILS_H
bool readLine(QFile *pFile, QString &szBuffer, bool bUtf8)
Reads a text line, returns false if EOF is reached.
Definition: KviFileUtils.cpp:328
void encodeFileName(QString &szPath)
Translates ANY string into a valid filename (with no path!)
Definition: KviFileUtils.cpp:392
bool directoryExists(const QString &szPath)
Returns true if szPath points to an existing directory.
Definition: KviFileUtils.cpp:368
bool copyFile(const QString &szSrc, const QString &szDst)
Copy the file (cp -f)
Definition: KviFileUtils.cpp:95
bool writeFile(const QString &szPath, const QByteArray &oData, bool bAppend)
Writes a complete file (UTF-8 version)
Definition: KviFileUtils.cpp:230
bool removeFile(const QString &szPath)
Removes a file.
Definition: KviFileUtils.cpp:171
bool isAbsolutePath(const QString &szPath)
Returns true if the path is absolute, false otherwise.
Definition: KviFileUtils.cpp:386
bool removeDir(const QString &szPath)
Removes a dir (must be empty)
Definition: KviFileUtils.cpp:183
bool renameFile(const QString &szSrc, const QString &szDst)
Rename or move the file (mv)
Definition: KviFileUtils.cpp:82
QString extractFilePath(const QString &szFileNameWithPath)
Extracts the filename from a complete path (strips leading path)
Definition: KviFileUtils.cpp:323
bool writeFileLocal8Bit(const QString &szPath, const QString &szData, bool bAppend)
Writes a complete file (local 8 bit version)
Definition: KviFileUtils.cpp:261
QString extractFileName(const QString &szFileNameWithPath, bool bAllowEmpty)
Extracts the filename from a complete path (strips leading path)
Definition: KviFileUtils.cpp:313
QStringList getFileListing(const QString &szPath)
Definition: KviFileUtils.cpp:470
void adjustFilePath(QString &szPath)
Adjusts the file path to the current platform.
Definition: KviFileUtils.cpp:148
bool makeDir(const QString &szPath)
Create a directory (mkdir)
Definition: KviFileUtils.cpp:42
void cleanFileName(QString &szPath)
Removes any unusable character from a filename (with no path!)
Definition: KviFileUtils.cpp:422
bool readLines(QFile *pFile, QStringList &buffer, int iStartLine, int iCount, bool bUtf8)
Reads text lines, returns false if EOF is reached.
Definition: KviFileUtils.cpp:343
bool deleteDir(const QString &szPath)
Removes a dir recursively.
Definition: KviFileUtils.cpp:195
char szBuffer[4096]
Definition: winamp.cpp:77
bool isReadable(const QString &szFname)
Returns true if the file is readable, false otherwise.
Definition: KviFileUtils.cpp:374
This file contains compile time settings.
bool fileExists(const QString &szPath)
Returns true if szPath points to an existing file.
Definition: KviFileUtils.h:91
#define KVILIB_API
Definition: kvi_settings.h:125
bool loadFile(const QString &szPath, QString &szBuffer, bool bUtf8)
Loads the file at szPath to szBuffer eventually converting from UTF-8.
Definition: KviFileUtils.cpp:130
bool readFile(const QString &szPath, QString &szBuffer, unsigned int uMaxSize)
Reads a complete file and puts it in the string szBuffer.
Definition: KviFileUtils.cpp:280