PLCnext API Documentation 25.0.2.69
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>

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. After successful operation, the synchronization of the file system will be enforced. More...
 
static void Delete (const String &path, bool sync)
 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. After successful operation, the synchronization of the file system will be enforced. More...
 
static void Copy (const String &sourcePath, const String &destinationPath, bool createDirectory, bool overwrite, bool sync)
 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. After successful operation, the synchronization of the file system will be enforced. More...
 
static void Move (const String &sourcePath, const String &destinationPath, bool createDirectory, bool overwrite, bool sync)
 Moves a file from source path to destination path. More...
 
static std::vector< byte > ReadAll (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. After successful operation, the synchronization of the file system will be forced. More...
 
static void WriteAll (const String &path, const std::vector< byte > &data, bool sync)
 Writes the data in data into file identified by path. More...
 
static void SyncAll (void)
 Force global file system synchronization.
 
static void Sync (const String &path)
 Force file system synchronization for the given file. More...
 

Detailed Description

API to manage and manipulate single files.

Member Function Documentation

◆ Copy() [1/2]

void Arp::System::Commons::Io::File::Copy ( const String sourcePath,
const String destinationPath,
bool  createDirectory,
bool  overwrite,
bool  sync 
)
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.
syncIf set to true, the synchronization of the file system is enforced after successful operation.
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

◆ Copy() [2/2]

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. After successful operation, the synchronization of the file system will be enforced.

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() [1/2]

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

Deletes the file from the filesystem. After successful operation, the synchronization of the file system will be enforced.

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.

◆ Delete() [2/2]

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

Deletes the file from the filesystem.

Parameters
pathFully qualified path of file.
syncIf set to true, the synchronization of the file system is enforced after successful operation.
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()

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() [1/2]

void Arp::System::Commons::Io::File::Move ( const String sourcePath,
const String destinationPath,
bool  createDirectory,
bool  overwrite,
bool  sync 
)
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.
syncIf set to true, the synchronization of the file system is enforced after successful operation.
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.

◆ Move() [2/2]

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. After successful operation, the synchronization of the file system will be enforced.

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()

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.

◆ Sync()

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

Force file system synchronization for the given file.

Parameters
pathPath to the file to be synchronized.

◆ WriteAll() [1/2]

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. After successful operation, the synchronization of the file system will be forced.

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

◆ WriteAll() [2/2]

void Arp::System::Commons::Io::File::WriteAll ( const String path,
const std::vector< byte > &  data,
bool  sync 
)
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.
syncIf set to true, the synchronization of the file system is enforced after successful operation.

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