1
1
// sktoolslib - common files for SK tools
2
2
3
- // Copyright (C) 2012, 2017-2022 - Stefan Kueng
3
+ // Copyright (C) 2012, 2017-2023 - Stefan Kueng
4
4
5
5
// This program is free software; you can redistribute it and/or
6
6
// modify it under the terms of the GNU General Public License
@@ -50,7 +50,7 @@ class CTextFile
50
50
/* *
51
51
* Saves the file contents to disk at \c path.
52
52
*/
53
- bool Save (LPCWSTR path, bool keepFileDate) const ;
53
+ bool Save (LPCWSTR path, bool keepFileDate) const ;
54
54
55
55
/* *
56
56
* modifies the contents of a file.
@@ -59,17 +59,17 @@ class CTextFile
59
59
* \param newLen length of the new file content in bytes
60
60
* \note the old buffer is automatically freed.
61
61
*/
62
- bool ContentsModified (std::unique_ptr<BYTE[]> pBuf, DWORD newLen);
62
+ bool ContentsModified (std::unique_ptr<BYTE[]> pBuf, DWORD newLen);
63
63
64
64
/* *
65
65
* Returns the line number from a given character position inside the file.
66
66
*/
67
- long LineFromPosition (long pos) const ;
67
+ long LineFromPosition (long pos) const ;
68
68
69
69
/* *
70
70
* Returns the line from a given line number
71
71
*/
72
- std::wstring GetLineString (long lineNumber) const ;
72
+ std::wstring GetLineString (long lineNumber) const ;
73
73
74
74
/* *
75
75
* Returns the file content as a text string.
@@ -81,17 +81,22 @@ class CTextFile
81
81
* Returns a pointer to the file contents. Call GetFileLength() to get
82
82
* the size in number of bytes of this buffer.
83
83
*/
84
- LPVOID GetFileContent () const { return pFileBuf.get (); }
84
+ LPVOID GetFileContent () const { return pFileBuf.get (); }
85
85
86
86
/* *
87
87
* Returns the size of the file in bytes
88
88
*/
89
- long GetFileLength () const { return fileLen; }
89
+ long GetFileLength () const { return fileLen; }
90
90
91
91
/* *
92
92
* Returns the encoding of the file
93
93
*/
94
- UnicodeType GetEncoding () const { return encoding; }
94
+ UnicodeType GetEncoding () const { return encoding; }
95
+
96
+ /* *
97
+ * Returns a string representation of the encoding
98
+ */
99
+ static std::wstring GetEncodingString (UnicodeType type);
95
100
96
101
/* *
97
102
* Returns the filename
@@ -101,26 +106,26 @@ class CTextFile
101
106
/* *
102
107
* Returns the filename without the extension (if any)
103
108
*/
104
- std::wstring GetFileNameWithoutExtension () const ;
109
+ std::wstring GetFileNameWithoutExtension () const ;
105
110
106
111
/* *
107
112
* Returns the filename extension (if any)
108
113
*/
109
- std::wstring GetFileNameExtension () const ;
114
+ std::wstring GetFileNameExtension () const ;
110
115
111
116
/* *
112
117
* Replaces the file content.
113
118
*/
114
- void SetFileContent (const std::wstring& content);
119
+ void SetFileContent (const std::wstring& content);
115
120
116
- bool HasBOM () const { return hasBOM; }
121
+ bool HasBOM () const { return hasBOM; }
117
122
118
123
/* *
119
124
* Sets the number of null bytes that are allowed for
120
125
* a file to still be considered text instead of binary
121
126
* in the encoding detection. Default is 2.
122
127
*/
123
- void SetNullbyteCountForBinary (int count) { nullByteCount = count; }
128
+ void SetNullbyteCountForBinary (int count) { nullByteCount = count; }
124
129
125
130
protected:
126
131
/* *
0 commit comments