2022-05-21 19:58:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "IOError.h"
|
|
|
|
#include "ListBase.h"
|
|
|
|
#include "StringBase.h"
|
|
|
|
#include "FileStream.h"
|
|
|
|
#include "StreamReader.h"
|
|
|
|
#include "StreamWriter.h"
|
|
|
|
#include "BinaryReader.h"
|
|
|
|
#include "BinaryWriter.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// Remove Win32 macros
|
|
|
|
//
|
|
|
|
|
|
|
|
namespace IO
|
|
|
|
{
|
|
|
|
class File
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Copies an existing file to a new file, overwriting if specified
|
2022-05-21 21:51:35 +02:00
|
|
|
static void Copy(const String& SourceFileName, const String& DestinationFileName, bool OverWrite = false);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Deletes a file permanently
|
2022-05-21 21:51:35 +02:00
|
|
|
static void Delete(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Decrypts a file from a NTFS volume
|
2022-05-21 21:51:35 +02:00
|
|
|
static void Decrypt(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Encrypts a file from a NTFS volume
|
2022-05-21 21:51:35 +02:00
|
|
|
static void Encrypt(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Whether or not the file exists
|
2022-05-21 21:51:35 +02:00
|
|
|
static bool Exists(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Moves an existing file to a new location, overwriting if specified
|
2022-05-21 21:51:35 +02:00
|
|
|
static void Move(const String& SourceFileName, const String& DestinationFileName, bool OverWrite = false);
|
2022-05-21 19:58:09 +02:00
|
|
|
|
|
|
|
// Creates a file in a particular path with ReadWrite access
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> Create(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens a file in a particular path with the given mode
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> Open(const String& FilePath, FileMode Mode);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens a file in a particular path with the given mode
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> Open(const String& FilePath, FileMode Mode, FileAccess Access);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens a file in a particular path with the given mode
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> Open(const String& FilePath, FileMode Mode, FileAccess Access, FileShare Share);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens a file in a particular path for reading
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> OpenRead(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens a file in a particular path for writing
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> OpenWrite(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Opens or creates a file in a particular path for appending
|
2022-05-21 21:51:35 +02:00
|
|
|
static std::unique_ptr<FileStream> OpenAppend(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
|
|
|
|
// Reads the entire specified file as a text
|
2022-05-21 21:51:35 +02:00
|
|
|
static String ReadAllText(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Reads the entire specified file as bytes
|
2022-05-21 21:51:35 +02:00
|
|
|
static List<uint8_t> ReadAllBytes(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Reads all the lines in the specified text file
|
2022-05-21 21:51:35 +02:00
|
|
|
static List<String> ReadAllLines(const String& FilePath);
|
2022-05-21 19:58:09 +02:00
|
|
|
|
|
|
|
// Writes the specified text to the a file
|
2022-05-21 21:51:35 +02:00
|
|
|
static void WriteAllText(const String& FilePath, const String& Text);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Writes the specified bytes to the file
|
2022-05-21 21:51:35 +02:00
|
|
|
static void WriteAllBytes(const String& FilePath, const List<uint8_t>& Bytes);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Writes the specified bytes to the file
|
2022-05-21 21:51:35 +02:00
|
|
|
static void WriteAllBytes(const String& FilePath, const uint8_t* Bytes, uint64_t Count);
|
2022-05-21 19:58:09 +02:00
|
|
|
// Writes the specified lines to the file
|
2022-05-21 21:51:35 +02:00
|
|
|
static void WriteAllLines(const String& FilePath, const List<String>& Lines);
|
2022-05-21 19:58:09 +02:00
|
|
|
};
|
|
|
|
}
|