#include "cpl_port.h"
#include "cpl_vsi.h"
#include "cpl_error.h"
Go to the source code of this file.
Classes | |
struct | CPLSharedFileInfo |
Defines | |
#define | CPLFree VSIFree |
Typedefs | |
typedef const char *(* | CPLFileFinder )(const char *, const char *) |
Functions | |
void | CPLVerifyConfiguration () |
const char * | CPLGetConfigOption (const char *, const char *) |
void | CPLSetConfigOption (const char *, const char *) |
void | CPLFreeConfig () |
void * | CPLMalloc (size_t) |
void * | CPLCalloc (size_t, size_t) |
void * | CPLRealloc (void *, size_t) |
char * | CPLStrdup (const char *) |
char * | CPLFGets (char *, int, FILE *) |
const char * | CPLReadLine (FILE *) |
char * | CPLScanString (const char *, int, int, int) |
double | CPLScanDouble (const char *, int, char *) |
long | CPLScanLong (const char *, int) |
GUIntBig | CPLScanUIntBig (const char *, int) |
void * | CPLScanPointer (const char *, int) |
int | CPLPrintString (char *, const char *, int) |
int | CPLPrintStringFill (char *, const char *, int) |
int | CPLPrintInt32 (char *, GInt32, int) |
int | CPLPrintUIntBig (char *, GUIntBig, int) |
int | CPLPrintDouble (char *, const char *, double, char *) |
int | CPLPrintTime (char *, int, const char *, const struct tm *, char *) |
int | CPLPrintPointer (char *, void *, int) |
void * | CPLGetSymbol (const char *, const char *) |
char ** | CPLReadDir (const char *pszPath) |
const char * | CPLGetPath (const char *) |
const char * | CPLGetDirname (const char *) |
const char * | CPLGetFilename (const char *) |
const char * | CPLGetBasename (const char *) |
const char * | CPLGetExtension (const char *) |
const char * | CPLFormFilename (const char *pszPath, const char *pszBasename, const char *pszExtension) |
const char * | CPLFormCIFilename (const char *pszPath, const char *pszBasename, const char *pszExtension) |
const char * | CPLResetExtension (const char *, const char *) |
const char * | CPLProjectRelativeFilename (const char *pszProjectDir, const char *pszSecondaryFilename) |
int | CPLIsFilenameRelative (const char *pszFilename) |
const char * | CPLExtractRelativePath (const char *, const char *, int *) |
const char * | CPLFindFile (const char *pszClass, const char *pszBasename) |
const char * | CPLDefaultFindFile (const char *pszClass, const char *pszBasename) |
void | CPLPushFileFinder (CPLFileFinder pfnFinder) |
CPLFileFinder | CPLPopFileFinder () |
void | CPLPushFinderLocation (const char *) |
void | CPLPopFinderLocation () |
void | CPLFinderClean () |
int | CPLStat (const char *, VSIStatBuf *) |
FILE * | CPLOpenShared (const char *, const char *, int) |
void | CPLCloseShared (FILE *) |
CPLSharedFileInfo * | CPLGetSharedList (int *) |
void | CPLDumpSharedList (FILE *) |
double | CPLDMSToDec (const char *is) |
const char * | CPLDecToDMS (double dfAngle, const char *pszAxis, int nPrecision) |
double | CPLPackedDMSToDec (double) |
double | CPLDecToPackedDMS (double dfDec) |
void | CPLStringToComplex (const char *pszString, double *pdfReal, double *pdfImag) |
int | CPLUnlinkTree (const char *) |
|
Safe version of calloc(). This function is like the C library calloc(), but raises a CE_Fatal error with CPLError() if it fails to allocate the desired memory. It should be used for small memory allocations that are unlikely to fail and for which the application is unwilling to test for out of memory conditions. It uses VSICalloc() to get the memory, so any hooking of VSICalloc() will apply to CPLCalloc() as well. CPLFree() or VSIFree() can be used free memory allocated by CPLCalloc().
|
|
Close shared file. Dereferences the indicated file handle, and closes it if the reference count has dropped to zero. A CPLError() is issued if the file is not in the shared file list.
|
|
Convert decimal degrees into packed DMS value (DDDMMMSSS.SS). This function converts a value, specified in decimal degrees into packed DMS angle. The standard packed DMS format is: degrees * 1000000 + minutes * 1000 + seconds See also CPLPackedDMSToDec().
|
|
Report open shared files. Dumps all open shared files to the indicated file handle. If the file handle is NULL information is sent via the CPLDebug() call.
|
|
Get relative path from directory to target file. Computes a relative path for pszTarget relative to pszBaseDir. Currently this only works if they share a common base path. The returned path is normally into the pszTarget string. It should only be considered valid as long as pszTarget is valid or till the next call to this function, whichever comes first.
|
|
Reads in at most one less than nBufferSize characters from the fp stream and stores them into the buffer pointed to by pszBuffer. Reading stops after an EOF or a newline. If a newline is read, it is _not_ stored into the buffer. A '' is stored after the last character in the buffer. All three types of newline terminators recognized by the CPLFGets(): single '' and '
|
|
Case insensitive file searching, returing full path. This function tries to return the path to a file regardless of whether the file exactly matches the basename, and extension case, or is all upper case, or all lower case. The path is treated as case sensitive. This function is equivelent to CPLFormFilename() on case insensitive file systems (like Windows).
|
|
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"
|
|
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/" ) == ""
|
|
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 the dot will be returned. It is the only difference from CPLGetPath().
CPLGetDirname( "abc/def.xyz" ) == "abc" CPLGetDirname( "/abc/def/" ) == "/abc/def" CPLGetDirname( "/" ) == "/" CPLGetDirname( "/abc/def" ) == "/abc" CPLGetDirname( "abc" ) == "."
|
|
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 not include the period.
CPLGetExtension( "abc/def.xyz" ) == "xyz" CPLGetExtension( "abc/def" ) == ""
|
|
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"
|
|
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" CPLGetPath( "abc" ) == ""
|
|
Fetch list of open shared files.
|
|
Fetch a function pointer from a shared library / DLL. This function is meant to abstract access to shared libraries and DLLs and performs functions similar to dlopen()/dlsym() on Unix and LoadLibrary() / GetProcAddress() on Windows. If no support for loading entry points from a shared library is available this function will always return NULL. Rules on when this function issues a CPLError() or not are not currently well defined, and will have to be resolved in the future. Currently CPLGetSymbol() doesn't try to:
Some of these issues may be worked on in the future.
|
|
Is filename relative or absolute? The test is filesystem convention agnostic. That is it will test for Unix style and windows style path conventions regardless of the actual system in use.
|
|
Safe version of malloc(). This function is like the C library malloc(), but raises a CE_Fatal error with CPLError() if it fails to allocate the desired memory. It should be used for small memory allocations that are unlikely to fail and for which the application is unwilling to test for out of memory conditions. It uses VSIMalloc() to get the memory, so any hooking of VSIMalloc() will apply to CPLMalloc() as well. CPLFree() or VSIFree() can be used free memory allocated by CPLMalloc().
|
|
Open a shared file handle. Some operating systems have limits on the number of file handles that can be open at one time. This function attempts to maintain a registry of already open file handles, and reuse existing ones if the same file is requested by another part of the application. Note that access is only shared for access types "r", "rb", "r+" and "rb+". All others will just result in direct VSIOpen() calls. Keep in mind that a file is only reused if the file name is exactly the same. Different names referring to the same file will result in different handles. The VSIFOpen() or VSIFOpenL() function is used to actually open the file, when an existing file handle can't be shared.
|
|
Convert a packed DMS value (DDDMMMSSS.SS) into decimal degrees. This function converts a packed DMS angle to seconds. The standard packed DMS format is: degrees * 1000000 + minutes * 1000 + seconds Example: ang = 120025045.25 yields deg = 120 min = 25 sec = 45.25 The algorithm used for the conversion is as follows: 1. The absolute value of the angle is used. 2. The degrees are separated out: deg = ang/1000000 (fractional portion truncated) 3. The minutes are separated out: min = (ang - deg * 1000000) / 1000 (fractional portion truncated) 4. The seconds are then computed: sec = ang - deg * 1000000 - min * 1000 5. The total angle in seconds is computed: sec = deg * 3600.0 + min * 60.0 + sec 6. The sign of sec is set to that of the input angle. Packed DMS values used by the USGS GCTP package and probably by other software. NOTE: This code does not validate input value. If you give the wrong value, you will get the wrong result.
|
|
Print double value into specified string buffer. Exponential character flag 'E' (or 'e') will be replaced with 'D', as in Fortran. Resulting string will not to be NULL-terminated.
|
|
Print GInt32 value into specified string buffer. This string will not be NULL-terminated.
|
|
Print pointer value into specified string buffer. This string will not be NULL-terminated.
|
|
Copy the string pointed to by pszSrc, NOT including the terminating `' character, to the array pointed to by pszDest.
|
|
Copy the string pointed to by pszSrc, NOT including the terminating `' character, to the array pointed to by pszDest. Remainder of the destination string will be filled with space characters. This is only difference from the PrintString().
|
|
Print specified time value accordingly to the format options and specified locale name. This function does following:
|
|
Print GUIntBig value into specified string buffer. This string will not be NULL-terminated.
|
|
Find a file relative to a project file. Given the path to a "project" directory, and a path to a secondary file referenced from that project, build a path to the secondary file that the current application can use. If the secondary path is already absolute, rather than relative, then it will be returned unaltered. Examples: CPLProjectRelativeFilename("abc/def","tmp/abc.gif") == "abc/def/tmp/abc.gif" CPLProjectRelativeFilename("abc/def","/tmp/abc.gif") == "/tmp/abc.gif" CPLProjectRelativeFilename("/xy", "abc.gif") == "/xy/abc.gif" CPLProjectRelativeFilename("/abc/def","../abc.gif") == "/abc/def/../abc.gif" CPLProjectRelativeFilename("C:\WIN","abc.gif") == "C:\WIN\abc.gif"
|
|
Read names in a directory. This function abstracts access to directory contains. It returns a list of strings containing the names of files, and directories in this directory. The resulting string list becomes the responsibility of the application and should be freed with CSLDestroy() when no longer needed. Note that no error is issued via CPLError() if the directory path is invalid, though NULL is returned.
|
|
Simplified line reading from text file. Read a line of text from the given file handle, taking care to capture CR and/or LF and strip off ... equivelent of DKReadLine(). Pointer to an internal buffer is returned. The application shouldn't free it, or depend on it's value past the next call to CPLReadLine(). Note that CPLReadLine() uses VSIFGets(), so any hooking of VSI file services should apply to CPLReadLine() as well. CPLReadLine() maintains an internal buffer, which will appear as a single block memory leak in some circumstances. CPLReadLine() may be called with a NULL FILE * at any time to free this working buffer.
|
|
Safe version of realloc(). This function is like the C library realloc(), but raises a CE_Fatal error with CPLError() if it fails to allocate the desired memory. It should be used for small memory allocations that are unlikely to fail and for which the application is unwilling to test for out of memory conditions. It uses VSIRealloc() to get the memory, so any hooking of VSIRealloc() will apply to CPLRealloc() as well. CPLFree() or VSIFree() can be used free memory allocated by CPLRealloc(). It is also safe to pass NULL in as the existing memory block for CPLRealloc(), in which case it uses VSIMalloc() to allocate a new block.
|
|
Replace the extension with the provided one.
|
|
Scan up to a maximum number of characters from a string and convert the result to a double.
|
|
Scan up to a maximum number of characters from a string and convert the result to a long.
|
|
Extract pointer from string. Scan up to a maximum number of characters from a string and convert the result to a GUIntBig.
|
|
Scan up to a maximum number of characters from a given string, allocate a buffer for a new string and fill it with scanned characters.
|
|
Extract big integer from string. Scan up to a maximum number of characters from a string and convert the result to a GUIntBig.
|
|
Safe version of strdup() function. This function is similar to the C library strdup() function, but if the memory allocation fails it will issue a CE_Fatal error with CPLError() instead of returning NULL. It uses VSIStrdup(), so any hooking of that function will apply to CPLStrdup() as well. Memory allocated with CPLStrdup() can be freed with CPLFree() or VSIFree(). It is also safe to pass a NULL string into CPLStrdup(). CPLStrdup() will allocate and return a zero length string (as opposed to a NULL string).
|