path.h File Reference

OS file-system path comparison, decomposition and manipulation. Paths are c-style null-terminated-character-arrays. Path separators must be forward slashes (unix style). Directory paths must end in a separator. Paths must not contain the ascii characters \ : * ? " < > or |. Paths may be encoded in UTF-8 or any extended-ascii character set. More...

#include <string>
#include "string/string.h"
#include <glib.h>
#include <glib/gstdio.h>
Include dependency graph for path.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  MatchFileExtension< Functor >
class  DirectoryCleaned

Namespaces

namespace  os

Defines

#define INCLUDED_OS_PATH_H

Functions

std::string os::standardPath (const std::string &inPath)
std::string os::getExtension (const std::string &path)
std::string os::getFilenameFromPath (const std::string &path)
std::string os::stripFilename (const std::string &filename)
std::string os::stripExtension (const std::string &filename)
bool path_is_directory (const std::string &path)
 Returns true if path is a directory. O(n).
const char * path_get_filename_start (const char *path)
 Returns a pointer to the first character of the filename component of path. O(n).
bool path_less (const char *path, const char *other)
 Returns true if path is lexicographically sorted before other. If both path and other refer to the same file, neither will be sorted before the other. O(n).
int path_compare (const char *path, const char *other)
 Returns <0 if path is lexicographically less than other. Returns >0 if path is lexicographically greater than other. Returns 0 if both path and other refer to the same file. O(n).
bool path_equal (const std::string &path, const std::string &other)
 Returns true if path and other refer to the same file or directory. O(n).
bool path_equal_n (const char *path, const char *other, std::size_t n)
 Returns true if the first n bytes of path and other form paths that refer to the same file or directory. If the paths are UTF-8 encoded, [path, path + n) must be a complete path. O(n).
const char * path_get_filename_base_end (const char *path)
 Returns a pointer to the character after the end of the filename component of path - either the extension separator or the terminating null character. O(n).
std::size_t path_get_filename_base_length (const char *path)
 Returns the length of the filename component (not including extension) of path. O(n).
const char * path_make_relative (const char *path, const char *base)
 If path is a child of base, returns the subpath relative to base, else returns path. O(n).
bool extension_equal (const std::string &extension, const std::string &other)
 Returns true if extension is of the same type as other. O(n).
template<typename TextOutputStreamType >
TextOutputStreamType & ostream_write (TextOutputStreamType &ostream, const DirectoryCleaned &path)
 Writes path to ostream with dos-style separators replaced by unix-style separators, and appends a separator if necessary.

Detailed Description

OS file-system path comparison, decomposition and manipulation. Paths are c-style null-terminated-character-arrays. Path separators must be forward slashes (unix style). Directory paths must end in a separator. Paths must not contain the ascii characters \ : * ? " < > or |. Paths may be encoded in UTF-8 or any extended-ascii character set.

Definition in file path.h.


Define Documentation

#define INCLUDED_OS_PATH_H

Definition at line 33 of file path.h.


Function Documentation

bool extension_equal ( const std::string extension,
const std::string other 
) [inline]

Returns true if extension is of the same type as other. O(n).

Definition at line 210 of file path.h.

References path_equal().

Referenced by MatchFileExtension< Functor >::operator()().

template<typename TextOutputStreamType >
TextOutputStreamType& ostream_write ( TextOutputStreamType &  ostream,
const DirectoryCleaned path 
) [inline]

Writes path to ostream with dos-style separators replaced by unix-style separators, and appends a separator if necessary.

Definition at line 246 of file path.h.

References i, and DirectoryCleaned::m_path.

int path_compare ( const char *  path,
const char *  other 
) [inline]

Returns <0 if path is lexicographically less than other. Returns >0 if path is lexicographically greater than other. Returns 0 if both path and other refer to the same file. O(n).

Definition at line 150 of file path.h.

bool path_equal ( const std::string path,
const std::string other 
) [inline]

Returns true if path and other refer to the same file or directory. O(n).

Definition at line 161 of file path.h.

Referenced by extension_equal().

bool path_equal_n ( const char *  path,
const char *  other,
std::size_t  n 
) [inline]

Returns true if the first n bytes of path and other form paths that refer to the same file or directory. If the paths are UTF-8 encoded, [path, path + n) must be a complete path. O(n).

Definition at line 173 of file path.h.

Referenced by path_make_relative().

const char* path_get_filename_base_end ( const char *  path  )  [inline]

Returns a pointer to the character after the end of the filename component of path - either the extension separator or the terminating null character. O(n).

Definition at line 184 of file path.h.

References path_get_filename_start().

Referenced by path_get_filename_base_length().

std::size_t path_get_filename_base_length ( const char *  path  )  [inline]

Returns the length of the filename component (not including extension) of path. O(n).

Definition at line 192 of file path.h.

References path_get_filename_base_end().

const char* path_get_filename_start ( const char *  path  )  [inline]

Returns a pointer to the first character of the filename component of path. O(n).

Definition at line 119 of file path.h.

Referenced by path_get_filename_base_end().

bool path_is_directory ( const std::string path  )  [inline]

Returns true if path is a directory. O(n).

Definition at line 109 of file path.h.

bool path_less ( const char *  path,
const char *  other 
) [inline]

Returns true if path is lexicographically sorted before other. If both path and other refer to the same file, neither will be sorted before the other. O(n).

Definition at line 137 of file path.h.

const char* path_make_relative ( const char *  path,
const char *  base 
) [inline]

If path is a child of base, returns the subpath relative to base, else returns path. O(n).

Definition at line 199 of file path.h.

References path_equal_n().


Generated by  doxygen 1.6.2