Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Tools.h File Reference

#include "nvsgcommon.h"
#include <vector>
#include "__WIN64__workarounds.h"

Include dependency graph for Tools.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  nvutil

Functions

NVSG_API bool FindFile (const std::string &mask, const std::vector< std::string > &searchPaths, std::vector< std::string > &results, bool recursive=false)
 Find files matching a pattern.
NVSG_API bool FindFileFirst (const std::string &mask, const std::vector< std::string > &searchPaths, std::string &nameOut, bool recursive=false)
 Check for the first occurence of a file.
NVSG_API bool FileExists (const std::string &filepath)
 Check if a given file exists.
NVSG_API void GetFileNameFromPath (const std::string &path, std::string &fname)
 Extract filename.
NVSG_API void GetFileExtFromPath (const std::string &path, std::string &fext)
 Extract file extension.
NVSG_API void GetDirFromPath (const std::string &path, std::string &dir)
 Extract directory path.
NVSG_API void GetDrvFromPath (const std::string &path, std::string &drv)
 Extract drive letter.
NVSG_API void GetDrvAndDirFromPath (const std::string &path, std::string &dir)
 Extract full path.
NVSG_API bool GetCurrentDir (std::string &path)
 Get the current directory for the current process.
template<typename T>
Maximum (T a, T b, T c)
template<typename T>
Minimum (T a, T b, T c)
NVSG_API std::string SetCurrentDir (const std::string &dir)
 Set the current directory for the current process.


Detailed Description


Function Documentation

NVSG_API bool FindFile const std::string &  mask,
const std::vector< std::string > &  searchPaths,
std::vector< std::string > &  results,
bool  recursive = false
 

Find files matching a pattern.

Tries to find files matching mask and output results (full path) to results

The function tries to lookup the file as follows:
  1. If mask contains a drive or path, that path will be looked for first
  2. If it does not contain a path and searchPaths is empty we look inside current dir for a match
  3. Look inside the search paths stored in searchPaths
  4. Dive into all the subdirs if recursive is set true
Note: Use FindFileFirst, if you are only interested in the first occurence of a file.

Returns:
true if successfull, false otherwise.
Parameters:
mask  the path/file mask to match
searchPaths  the dirs to addtionally search
results  store results in here
recursive  search all subdirs also

NVSG_API bool FindFileFirst const std::string &  mask,
const std::vector< std::string > &  searchPaths,
std::string &  nameOut,
bool  recursive = false
 

Check for the first occurence of a file.

Works as FindFile, but return the first match only to nameOut

Parameters:
mask  Name of the file to search for.
searchPaths  Collection of search pathes to lookup the file.
nameOut  Holds the full path and filename, if successfull.
recursive  search all subdirs also

NVSG_API bool FileExists const std::string &  filepath  ) 
 

Check if a given file exists.

NVSG_API void GetFileNameFromPath const std::string &  path,
std::string &  fname
 

Extract filename.

Extracts the filename with extension from path and returns it in fname.

Parameters:
path  Input path and filename.
fname  Extracted filename with extension.

NVSG_API void GetFileExtFromPath const std::string &  path,
std::string &  fext
 

Extract file extension.

Extracts the file extension, including leading period from path and returns it in fext.

Parameters:
path  Input path and filename.
fext  Extracted file extension, including leading period.

NVSG_API void GetDirFromPath const std::string &  path,
std::string &  dir
 

Extract directory path.

Extracts the directory path, including trailing slash from path and returns it in dir.

Parameters:
path  Input path and filename.
dir  Extracted directory path, including trailing slash.

NVSG_API void GetDrvFromPath const std::string &  path,
std::string &  drv
 

Extract drive letter.

Extracts the optional drive letter, followed by a colon from path and returns it in drv.

Parameters:
path  Input path and filename.
drv  Extracted drive letter, followed by a colon.

NVSG_API void GetDrvAndDirFromPath const std::string &  path,
std::string &  dir
 

Extract full path.

Extracts the drive and directory from path and returns it in dir.

Parameters:
path  Input path and filename.
dir  Extracted path, including trailing slash.

NVSG_API bool GetCurrentDir std::string &  path  ) 
 

Get the current directory for the current process.

path will hold the current directory if the function succeeds

Returns:
true if successful, false otherwise.
Parameters:
path  Holds the current directory if the function succeeds.

NVSG_API std::string SetCurrentDir const std::string &  dir  ) 
 

Set the current directory for the current process.

Sets the current directory for the current process to path and returns the former current directory.

Returns:
A string holding the former current directory.
Parameters:
dir  Path to be set as current directory.


Generated on Tue Mar 1 13:20:11 2005 for NVSGSDK by NVIDIA