CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
System::IO::Path Class Reference

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...

#include <path.h>

Static Public Member Functions

static String ChangeExtension (const String &path, const String &extension)
 Changes the extension in the specified file path. More...
 
static 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 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 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 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 String GetDirectoryName (const String &path)
 Returns the name of the directory referenced by the specified path. More...
 
static String GetExtension (const String &path)
 Returns the extension of the file referenced by the specified path. More...
 
static String GetFileName (const String &path)
 Returns the name of the file referenced by the specified path. More...
 
static String GetFileNameWithoutExtension (const String &path)
 Returns the name without extension of the file referenced by the specified path. More...
 
static String GetFullPath (const String &path)
 Converts the specified path into absolute path. More...
 
static ArrayPtr< char_t > GetInvalidFileNameChars ()
 Returns an array containing characters that are not allowed in the names of files. More...
 
static ArrayPtr< char_t > GetInvalidPathChars ()
 Returns an array containing characters that are not allowed in path names. More...
 
static String GetPathRoot (const String &path)
 Returns the root directory of the specified path. More...
 
static String GetRandomFileName ()
 Returns a randomly generated file name. More...
 
static String GetTempFileName_ ()
 Creates a new file with a unique name and returns a full path to it. More...
 
static 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 String GetTempPath ()
 Returns the path of the current user's temporary directory. More...
 
static bool HasExtension (const String &path)
 Determines if the specified path references a file with extension. More...
 
static bool IsPathRooted (const String &path)
 Determines if the specified path contains a root. More...
 
static 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 String ToString (const boost::filesystem::path &path)
 Returns a string representation of the specified Boost's path object. More...
 
static boost::filesystem::path ToBoost (const String &path)
 Returns an instance of boost::filesystem::path class that represents the specified path. More...
 
static String NormalizePath (const String &path)
 Normalizes the specified path. More...
 

Static Public Attributes

static const char_t AltDirectorySeparatorChar
 An alternate character used to separate directory levels in a path. More...
 
static const char_t DirectorySeparatorChar
 A character used to separate directory levels in a path. More...
 
static const char_t PathSeparator
 A separator character used to separate path strings in environment variables. More...
 
static const char_t VolumeSeparatorChar
 A volume separator character. More...
 
static 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
*/
static String GetRandomFileName()
Returns a randomly generated file name.
static String GetFileName(const String &path)
Returns the name of the file referenced by the specified path.
static String GetExtension(const String &path)
Returns the extension of the file referenced by the specified path.
static String GetFileNameWithoutExtension(const String &path)
Returns the name without extension of the file referenced by the specified path.
Definition: fwd.h:38

Member Function Documentation

◆ ChangeExtension()

static 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 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 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 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 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 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 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 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 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 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 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 ArrayPtr< char_t > System::IO::Path::GetInvalidFileNameChars ( )
static

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

◆ GetInvalidPathChars()

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

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

◆ GetPathRoot()

static 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 String System::IO::Path::GetRandomFileName ( )
static

Returns a randomly generated file name.

◆ GetTempFileName_()

static 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 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 String System::IO::Path::GetTempPath ( )
static

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

◆ HasExtension()

static 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 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 String System::IO::Path::NormalizePath ( const String path)
static

Normalizes the specified path.

Parameters
pathA path to normalize
Returns
The normalized path

◆ ToBoost()

static 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 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 System::IO::Path::AltDirectorySeparatorChar
static

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

◆ DirectorySeparatorChar

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

A character used to separate directory levels in a path.

◆ PathSeparator

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

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

◆ s_msg_path

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

Default parameter name for CheckPath function.

◆ VolumeSeparatorChar

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

A volume separator character.