/// <summary>Get the file path of the file.</summary>
/// <returns>The file path.</returns>
const
FilePath
&
GetFilePath
()
const
;
/// <summary>Get the content of a text file with encoding testing.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="text">Returns the content of the file.</param>
/// <param name="encoding">Returns the encoding of the file.</param>
/// <param name="containsBom">Returns true if there is a BOM in the file.</param>
bool
ReadAllTextWithEncodingTesting
(
WString
&
text
,
stream
::
BomEncoder
::
Encoding
&
encoding
,
bool
&
containsBom
);
/// <summary>Get the content of a text file. If there is no BOM in the file, the encoding is assumed to be aligned to the current code page.</summary>
/// <returns>The content of the file.</returns>
WString
ReadAllTextByBom
()
const
;
/// <summary>Get the content of a text file.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="text">The content of the file.</param>
bool
ReadAllTextByBom
(
WString
&
text
)
const
;
/// <summary>Get the content of a text file by lines.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="lines">The content of the file by lines.</param>
/// <remarks>
/// Lines could be separated by either CRLF or LF.
/// A text file is not required to ends with CRLF.
/// If the last character of the file is LF,
/// the last line is the line before LF.
/// </remarks>
bool
ReadAllLinesByBom
(
collections
::
List
<
WString
>&
lines
)
const
;
/// <summary>Write text to the file.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="text">The text to write.</param>
/// <param name="bom">Set to true to add a corresponding BOM at the beginning of the file according to the encoding, the default value is true.</param>
/// <param name="encoding">The text encoding, the default encoding is UTF-16.</param>
bool
WriteAllText
(
const
WString
&
text
,
bool
bom
=
true
,
stream
::
BomEncoder
::
Encoding
encoding
=
stream
::
BomEncoder
::
Utf16
);
/// <summary>Write text to the file.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="lines">The text to write, with CRLF appended after all lines.</param>
/// <param name="bom">Set to true to add a corresponding BOM at the beginning of the file according to the encoding, the default value is true.</param>
/// <param name="encoding">The text encoding, the default encoding is UTF-16.</param>
bool
WriteAllLines
(
collections
::
List
<
WString
>&
lines
,
bool
bom
=
true
,
stream
::
BomEncoder
::
Encoding
encoding
=
stream
::
BomEncoder
::
Utf16
);
/// <summary>Test does the file exist or not.</summary>
/// <returns>Returns true if the file exists.</returns>
bool
Exists
()
const
;
/// <summary>Delete the file.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <remarks>This function could return before the file is actually deleted.</remarks>
bool
Delete
()
const
;
/// <summary>Rename the file.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="newName">The new file name.</param>
bool
Rename
(
const
WString
&
newName
)
const
;
};
/// <summary>A folder.</summary>
/// <remarks>In Windows, a drive is also considered a folder.</remarks>
class
Folder
:
public
Object
{
private
:
FilePath
filePath
;
public
:
/// <summary>Create a reference to the root folder.</summary>
Folder
();
/// <summary>Create a reference to a specified folder. The folder is not required to exist.</summary>