-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileutil.h
50 lines (44 loc) · 1.21 KB
/
fileutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef FILEUTIL_H
#define FILEUTIL_H
class QString;
#include <QDateTime>
enum class EncodingFormat:int
{
ANSI = 0,//GBK
UTF16LE,
UTF16BE,
UTF8,
UTF8BOM,
};
class AppendInterface{
public:
virtual void append(QString line) = 0;
virtual void clear() = 0;
};
typedef std::pair<QString,QString> NameUrl;
class FileUtil
{
private:
FileUtil() = delete;
public:
/** read file to append in text
* @brief readFileToShow
* @param filePath
* @param ap
*/
static void readFileToShow(QString filePath,AppendInterface *ap);
static EncodingFormat FileCharacterEncoding(const QString &fileName);
static QString sizeFormat(qint64 size);
static const QString TIME_FORMAT ;
static inline QString timeStr(const QDateTime & datetime){
return datetime.toString(TIME_FORMAT);
}
static void defaultOpen(QString filepaths);
static QList<NameUrl> generatePathUrls(QString filePath);
static QString generateFileLink(QString filePath);
/*
* generate a new file , if filename exists, add one int to filename. /home/ljl/abc.txt => /home/ljl/abc0.txt
*/
static QString getNewFile(QString path, QString fileName);
};
#endif // FILEUTIL_H