Provides methods for manipulating paths. This is a static type with no instance services. You should never create instances of it by any means. More...

Static Public Member Functions

static ASPOSECPP_SHARED_API String ChangeExtension (const String &path, const String &extension)
 Changes the extension in the specified file path. More...
 
static ASPOSECPP_SHARED_API String Combine (const ArrayPtr< String > &paths)
 Combines the specified path segments into a single path inserting directory separator characters between the segments if necessary. More...
 
static ASPOSECPP_SHARED_API String Combine (const String &path1, const String &path2)
 Combines two specified path segments into a single path inserting directory separator character between the segments if necessary. More...
 
static ASPOSECPP_SHARED_API String Combine (const String &path1, const String &path2, const String &path3)
 Combines three specified path segments into a single path inserting directory separator characters between the segments if necessary. More...
 
static ASPOSECPP_SHARED_API String Combine (const String &path1, const String &path2, const String &path3, const String &path4)
 Combines four specified path segments into a single path inserting directory separator characters between the segments if necessary. More...
 
static ASPOSECPP_SHARED_API String GetDirectoryName (const String &path)
 Returns the name of the directory referenced by the specified path. More...
 
static ASPOSECPP_SHARED_API String GetExtension (const String &path)
 Returns the extension of the file referenced by the specified path. More...
 
static ASPOSECPP_SHARED_API String GetFileName (const String &path)
 Returns the name of the file referenced by the specified path. More...
 
static ASPOSECPP_SHARED_API String GetFileNameWithoutExtension (const String &path)
 Returns the name without extension of the file referenced by the specified path. More...
 
static ASPOSECPP_SHARED_API String GetFullPath (const String &path)
 Converts the specified path into absolute path. More...
 
static ASPOSECPP_SHARED_API ArrayPtr< char_t > GetInvalidFileNameChars ()
 Returns an array containing characters that are not allowed in the names of files. More...
 
static ASPOSECPP_SHARED_API ArrayPtr< char_t > GetInvalidPathChars ()
 Returns an array containing characters that are not allowed in path names. More...
 
static ASPOSECPP_SHARED_API String GetPathRoot (const String &path)
 Returns the root directory of the specified path. More...
 
static ASPOSECPP_SHARED_API String GetRandomFileName ()
 Returns a randomly generated file name. More...
 
static ASPOSECPP_SHARED_API String GetTempFileName_ ()
 Creates a new file with a unique name and returns a full path to it. More...
 
static ASPOSECPP_SHARED_API String GetTempFileNameSafe ()
 Creates a new file with a unique name and returns a full path to it. Is a synonym of GetTempFileName_() method. More...
 
static ASPOSECPP_SHARED_API String GetTempPath ()
 Returns the path of the current user's temporary directory. More...
 
static ASPOSECPP_SHARED_API bool HasExtension (const String &path)
 Determines if the specified path references a file with extension. More...
 
static ASPOSECPP_SHARED_API bool IsPathRooted (const String &path)
 Determines if the specified path contains a root. More...
 
static ASPOSECPP_SHARED_API void CheckPath (const String &path, const String &msg=s_msg_path, bool allow_empty=true)
 Determines if the specified path is valid by checking if it contains invalid characters. An exception is thrown if the path contains invalid characters. More...
 
static ASPOSECPP_SHARED_API String ToString (const boost::filesystem::path &path)
 Returns a string representation of the specified Boost's path object. More...
 
static ASPOSECPP_SHARED_API boost::filesystem::path ToBoost (const String &path)
 Returns an instance of boost::filesystem::path class that represents the specified path. More...
 
static ASPOSECPP_SHARED_API String NormalizePath (const String &path)
 Normalizes the specified path. More...
 

Static Public Attributes

static const char_t ASPOSECPP_SHARED_API AltDirectorySeparatorChar
 An alternate character used to separate directory levels in a path. More...
 
static const char_t ASPOSECPP_SHARED_API DirectorySeparatorChar
 A character used to separate directory levels in a path. More...
 
static const char_t ASPOSECPP_SHARED_API PathSeparator
 A separator character used to separate path strings in environment variables. More...
 
static const char_t ASPOSECPP_SHARED_API VolumeSeparatorChar
 A volume separator character. More...
 
static ASPOSECPP_SHARED_API const String s_msg_path
 Default parameter name for CheckPath function. More...
 

Detailed Description

Provides methods for manipulating paths. This is a static type with no instance services. You should never create instances of it by any means.

#include "system/io/path.h"
#include <iostream>
int main()
{
using namespace System::IO;
// Generate a random filename.
auto filename = Path::GetRandomFileName();
// Print information about file name.
std::cout <<
"Filename: " << Path::GetFileName(filename) << std::endl <<
"Filename w/o an extension: " << Path::GetFileNameWithoutExtension(filename) << std::endl <<
"Extension: " << Path::GetExtension(filename) << std::endl;
return 0;
}
/*
This code example produces the following output:
Filename: qhuzkyqv.y6p
Filename w/o an extension: qhuzkyqv
Extension: .y6p
*/

Member Function Documentation

◆ ChangeExtension()

static ASPOSECPP_SHARED_API String System::IO::Path::ChangeExtension ( const String path,
const String extension 
)
static

Changes the extension in the specified file path.

Parameters
pathA file path
extensionThe extension to replace the one in path with
Returns
path with extension replaced with extension

◆ CheckPath()

static ASPOSECPP_SHARED_API void System::IO::Path::CheckPath ( const String path,
const String msg = s_msg_path,
bool  allow_empty = true 
)
static

Determines if the specified path is valid by checking if it contains invalid characters. An exception is thrown if the path contains invalid characters.

Parameters
pathThe path to check
msgThe message to pass to the exception object's constructor
allow_emptySpecifies whether an empty or null string should be considered a correct path (true) or not (false); if this parameter is false and path is empty an ArgumentException is thrown; if this parameter is false and path is null an ArgumentNullException is thrown

◆ Combine() [1/4]

static ASPOSECPP_SHARED_API String System::IO::Path::Combine ( const ArrayPtr< String > &  paths)
static

Combines the specified path segments into a single path inserting directory separator characters between the segments if necessary.

Parameters
pathsAn array containing path segments to combine
Returns
The combined path

◆ Combine() [2/4]

static ASPOSECPP_SHARED_API String System::IO::Path::Combine ( const String path1,
const String path2 
)
static

Combines two specified path segments into a single path inserting directory separator character between the segments if necessary.

Parameters
path1The first path segment
path2The second path segment
Returns
The combined path

◆ Combine() [3/4]

static ASPOSECPP_SHARED_API String System::IO::Path::Combine ( const String path1,
const String path2,
const String path3 
)
static

Combines three specified path segments into a single path inserting directory separator characters between the segments if necessary.

Parameters
path1The first path segment
path2The second path segment
path3The third path segment
Returns
The combined path

◆ Combine() [4/4]

static ASPOSECPP_SHARED_API String System::IO::Path::Combine ( const String path1,
const String path2,
const String path3,
const String path4 
)
static

Combines four specified path segments into a single path inserting directory separator characters between the segments if necessary.

Parameters
path1The first path segment
path2The second path segment
path3The third path segment
path4The fourth path segment
Returns
The combined path

◆ GetDirectoryName()

static ASPOSECPP_SHARED_API String System::IO::Path::GetDirectoryName ( const String path)
static

Returns the name of the directory referenced by the specified path.

Parameters
pathA path to a directory
Returns
The directory's name

◆ GetExtension()

static ASPOSECPP_SHARED_API String System::IO::Path::GetExtension ( const String path)
static

Returns the extension of the file referenced by the specified path.

Parameters
pathA path to a file
Returns
The extension of the file

◆ GetFileName()

static ASPOSECPP_SHARED_API String System::IO::Path::GetFileName ( const String path)
static

Returns the name of the file referenced by the specified path.

Parameters
pathA path to a file
Returns
The file's name

◆ GetFileNameWithoutExtension()

static ASPOSECPP_SHARED_API String System::IO::Path::GetFileNameWithoutExtension ( const String path)
static

Returns the name without extension of the file referenced by the specified path.

Parameters
pathA path to a file
Returns
The file's name without extension

◆ GetFullPath()

static ASPOSECPP_SHARED_API String System::IO::Path::GetFullPath ( const String path)
static

Converts the specified path into absolute path.

Parameters
pathThe path to convert
Returns
The absolute path referencing the same entity (which does not have to exist) as path

◆ GetInvalidFileNameChars()

static ASPOSECPP_SHARED_API ArrayPtr<char_t> System::IO::Path::GetInvalidFileNameChars ( )
static

Returns an array containing characters that are not allowed in the names of files.

◆ GetInvalidPathChars()

static ASPOSECPP_SHARED_API ArrayPtr<char_t> System::IO::Path::GetInvalidPathChars ( )
static

Returns an array containing characters that are not allowed in path names.

◆ GetPathRoot()

static ASPOSECPP_SHARED_API String System::IO::Path::GetPathRoot ( const String path)
static

Returns the root directory of the specified path.

Parameters
pathThe path from which to obtain the root
Returns
The root directory of path

◆ GetRandomFileName()

static ASPOSECPP_SHARED_API String System::IO::Path::GetRandomFileName ( )
static

Returns a randomly generated file name.

◆ GetTempFileName_()

static ASPOSECPP_SHARED_API String System::IO::Path::GetTempFileName_ ( )
static

Creates a new file with a unique name and returns a full path to it.

Returns
A full path to the created file

◆ GetTempFileNameSafe()

static ASPOSECPP_SHARED_API String System::IO::Path::GetTempFileNameSafe ( )
static

Creates a new file with a unique name and returns a full path to it. Is a synonym of GetTempFileName_() method.

Returns
A full path to the created file

◆ GetTempPath()

static ASPOSECPP_SHARED_API String System::IO::Path::GetTempPath ( )
static

Returns the path of the current user's temporary directory.

◆ HasExtension()

static ASPOSECPP_SHARED_API bool System::IO::Path::HasExtension ( const String path)
static

Determines if the specified path references a file with extension.

Parameters
pathA path to check
Returns
True if path references a file with extension, otherwise - false

◆ IsPathRooted()

static ASPOSECPP_SHARED_API bool System::IO::Path::IsPathRooted ( const String path)
static

Determines if the specified path contains a root.

Parameters
pathA path to check
Returns
True if path contains a root, otherwise - false

◆ NormalizePath()

static ASPOSECPP_SHARED_API String System::IO::Path::NormalizePath ( const String path)
static

Normalizes the specified path.

Parameters
pathA path to normalize
Returns
The normalized path

◆ ToBoost()

static ASPOSECPP_SHARED_API boost::filesystem::path System::IO::Path::ToBoost ( const String path)
static

Returns an instance of boost::filesystem::path class that represents the specified path.

Parameters
pathA path
Returns
a new instance of boost::filesystem::path class that represents path

◆ ToString()

static ASPOSECPP_SHARED_API String System::IO::Path::ToString ( const boost::filesystem::path &  path)
static

Returns a string representation of the specified Boost's path object.

Parameters
pathThe boost::filesystem::path object to convert to string
Returns
A string representation of path

Member Data Documentation

◆ AltDirectorySeparatorChar

const char_t ASPOSECPP_SHARED_API System::IO::Path::AltDirectorySeparatorChar
static

An alternate character used to separate directory levels in a path.

◆ DirectorySeparatorChar

const char_t ASPOSECPP_SHARED_API System::IO::Path::DirectorySeparatorChar
static

A character used to separate directory levels in a path.

◆ PathSeparator

const char_t ASPOSECPP_SHARED_API System::IO::Path::PathSeparator
static

A separator character used to separate path strings in environment variables.

◆ s_msg_path

ASPOSECPP_SHARED_API const String System::IO::Path::s_msg_path
static

Default parameter name for CheckPath function.

◆ VolumeSeparatorChar

const char_t ASPOSECPP_SHARED_API System::IO::Path::VolumeSeparatorChar
static

A volume separator character.