PLCnext API Documentation  21.0.0.35466
Public Member Functions | Static Public Member Functions | List of all members
Arp::System::Commons::Io::File Class Reference

API to manage and manipulate single files. More...

#include <File.hpp>

Public Member Functions

 File (const File &arg)=delete
 
Fileoperator= (const File &arg)=delete
 

Static Public Member Functions

static bool Exists (const String &path)
 Checks for existence of a file. More...
 
static void Delete (const String &path)
 Deletes the file from the filesystem. More...
 
static void Copy (const String &sourcePath, const String &destinationPath, bool createDirectory=true, bool overwrite=true)
 Copies a file from source path to destination path. More...
 
static void Move (const String &sourcePath, const String &destinationPath, bool createDirectory=true, bool overwrite=true)
 Moves a file from source path to destination path. More...
 
static std::vector< byteReadAll (const String &path)
 Reads data from file and returns it as byte array. More...
 
static void WriteAll (const String &path, const std::vector< byte > &data)
 Writes the data in data into file identified by path. More...
 

Detailed Description

API to manage and manipulate single files.

Member Function Documentation

◆ Copy()

static void Arp::System::Commons::Io::File::Copy ( const String sourcePath,
const String destinationPath,
bool  createDirectory = true,
bool  overwrite = true 
)
static

Copies a file from source path to destination path.

Parameters
sourcePathFully qualified path of file which should be copied.
destinationPathFully qualified path to destination of copied file. If the path contains a filename the copied file will also be renamed.
createDirectorySet to true if destinationPath does not exist and should be created during copy.
overwriteIf set to true and destinationPath already exists, it will be overwritten.
Exceptions
Arp::System::Commons::Io::AlreadyExistsExceptionif destinationPath already exists and overwrite is set to false
Arp::System::Commons::Io::NotExistExceptionif createDirectory is set to false but the destination directory does not exists.
Arp::System::Commons::Io::AccessDeniedExceptionif the process does not have write permission at destinationPath

◆ Delete()

static void Arp::System::Commons::Io::File::Delete ( const String path)
static

Deletes the file from the filesystem.

Parameters
pathFully qualified path of file.
Exceptions
Arp::System::Commons::Io::AccessDeniedExceptionif process does not have permission to delete the file.
Arp::System::Commons::Io::NotExistExceptionif the file does not exists.

◆ Exists()

static bool Arp::System::Commons::Io::File::Exists ( const String path)
static

Checks for existence of a file.

Parameters
pathFully qualified path of file.
Returns
True if file identified by path exists, otherwise false is returned.

◆ Move()

static void Arp::System::Commons::Io::File::Move ( const String sourcePath,
const String destinationPath,
bool  createDirectory = true,
bool  overwrite = true 
)
static

Moves a file from source path to destination path.

Parameters
sourcePathFully qualified path of file which should be moved.
destinationPathFully qualified path to destination of copied file. If the path contains a filename the moved file will also be renamed.
createDirectorySet to true if destinationPath does not exist and should be created during move.
overwriteIf set to true and destinationPath already exists, it will be overwritten.
Exceptions
Arp::System::Commons::Io::AlreadyExistsExceptionif destinationPath already exists and overwrite is set to false
Arp::System::Commons::Io::NotExistExceptionif createDirectory is set to false but the destination directory does not exists.
Arp::System::Commons::Io::AccessDeniedExceptionif the process does not have write permission at destinationPath or sourcePath.

◆ ReadAll()

static std::vector<byte> Arp::System::Commons::Io::File::ReadAll ( const String path)
static

Reads data from file and returns it as byte array.

Parameters
pathFully qualified path to file to be read.
Returns
Vector/Array of bytes read from file.

◆ WriteAll()

static void Arp::System::Commons::Io::File::WriteAll ( const String path,
const std::vector< byte > &  data 
)
static

Writes the data in data into file identified by path.

Parameters
pathFully qualified path to file to write to.
dataVector of bytes that should be written into file path.

The documentation for this class was generated from the following file: