Main Page Class Hierarchy Compound List File List Compound Members File Members Related Pages

# cpl_conv.h File Reference

Various convenience functions for CPL. More...

`#include "cpl_port.h"`
`#include "cpl_vsi.h"`
`#include "cpl_error.h"`

Go to the source code of this file.

## Defines
#define | CPLFree VSIFree
## Typedefs
typedef const char* (* | CPLFileFinder )(const char *, const char *)
## Functions
void CPL_DLL* | CPLGetSymbol ( const char *, const char * )
char CPL_DLL** | CPLReadDir ( const char *pszPath )
const char CPL_DLL* | CPLGetPath ( const char * )
| Extract directory path portion of filename. More...
const char CPL_DLL* | CPLGetFilename ( const char * )
| Extract non-directory portion of filename. More...
const char CPL_DLL* | CPLGetBasename ( const char * )
| Extract basename (non-directory, non-extension) portion of filename. More...
const char CPL_DLL* | CPLGetExtension ( const char * )
| Extract filename extension from full filename. More...
const char CPL_DLL* | CPLFormFilename ( const char *pszPath, const char *pszBasename, const char *pszExtension )
| Build a full file path from a passed path, file basename and extension. More...
const char CPL_DLL* | CPLFindFile (const char *pszClass, const char *pszBasename)
const char CPL_DLL* | CPLDefaultFindFile (const char *pszClass, const char *pszBasename)
void CPL_DLL | CPLPushFileFinder ( CPLFileFinder pfnFinder )
CPLFileFinder CPL_DLL | CPLPopFileFinder ()
void CPL_DLL | CPLPushFinderLocation ( const char * )

## Detailed Description

Various convenience functions for CPL.

## Function Documentation

const char * CPLFormFilename ( | const char * pszPath,
| const char * pszBasename,
| const char * pszExtension )

| Build a full file path from a passed path, file basename and extension. The path, and extension are optional. The basename may in fact contain an extension if desired.
     CPLFormFilename("abc/xyz","def", ".dat" ) == "abc/xyz/def.dat"
     CPLFormFilename(NULL,"def", NULL ) == "def"
     CPLFormFilename(NULL,"abc/def.dat", NULL ) == "abc/def.dat"
     CPLFormFilename("/abc/xyz/","def.dat", NULL ) == "/abc/xyz/def.dat"
  Parameters:
  pszPath | directory path to the directory containing the file. This may be relative or absolute, and may have a trailing path separator or not. May be NULL.
  pszBasename | file basename. May optionally have path and/or extension. May not be NULL.
  pszExtension | file extension, optionally including the period. May be NULL.
Returns: a fully formed filename in an internal static string. Do not modify or free the returned string. The string may be destroyed by the next CPL call.

const char * CPLGetBasename ( | const char * pszFullFilename )

| Extract basename (non-directory, non-extension) portion of filename. Returns a string containing the file basename portion of the passed name. If there is no basename (passed value ends in trailing directory separator, or filename starts with a dot) an empty string is returned.
     CPLGetBasename( "abc/def.xyz" ) == "def"
     CPLGetBasename( "abc/def" ) == "def"
     CPLGetBasename( "abc/def/" ) == ""
  Parameters:
  pszFullFilename | the full filename potentially including a path.
Returns: just the non-directory, non-extension portion of the path in an internal string which must not be freed. The string may be destroyed by the next CPL filename handling call.

const char * CPLGetExtension ( | const char * pszFullFilename )

| Extract filename extension from full filename. Returns a string containing the extention portion of the passed name. If there is no extension (the filename has no dot) an empty string is returned. The returned extension will always include the period.
     CPLGetExtension( "abc/def.xyz" ) == ".xyz"
     CPLGetExtension( "abc/def" ) == ""
  Parameters:
  pszFullFilename | the full filename potentially including a path.
Returns: just the extension portion of the path in an internal string which must not be freed. The string may be destroyed by the next CPL filename handling call.

const char * CPLGetFilename ( | const char * pszFullFilename )

| Extract non-directory portion of filename. Returns a string containing the bare filename portion of the passed filename. If there is no filename (passed value ends in trailing directory separator) an empty string is returned.
     CPLGetFilename( "abc/def.xyz" ) == "def.xyz"
     CPLGetFilename( "/abc/def/" ) == ""
     CPLGetFilename( "abc/def" ) == "def"
  Parameters:
  pszFullFilename | the full filename potentially including a path.
Returns: just the non-directory portion of the path in an internal string which must not be freed. The string may be destroyed by the next CPL filename handling call.

const char * CPLGetPath ( | const char * pszFilename )

| Extract directory path portion of filename. Returns a string containing the directory path portion of the passed filename. If there is no path in the passed filename an empty string will be returned (not NULL).
     CPLGetPath( "abc/def.xyz" ) == "abc"
     CPLGetPath( "/abc/def/" ) == "abc/def"
     CPLGetPath( "/" ) == "/"
     CPLGetPath( "/abc/def" ) == "/abc"
  Parameters:
  pszFilename | the filename potentially including a path.
Returns: Path in an internal string which must not be freed. The string may be destroyed by the next CPL filename handling call. The returned will generally not contain a trailing path separator.