FARGOS/VISTA Object Management Environment Core
..
|
Utility functions to create and open memory-mapped files. More...
Macros | |
#define | FILENAME_WITH_DATE 1 |
#define | FILENAME_WITH_PID 2 |
#define | FILENAME_WITH_DATE_AND_PID 3 |
#define | FILENAME_WITH_TIME 4 |
#define | FILENAME_WITH_DATE_AND_TIME 5 |
#define | FILENAME_WITH_HOST 8 |
#define | FILENAME_ADD_DIR_PREFIX 16 |
#define | FILENAME_WITH_EVERYTHING ~0 |
#define | MAP_FILE_READONLY 0 |
#define | MAP_FILE_READWRITE 1 |
#define | MAP_FILE_RESET 2 |
#define | MAP_FILE_INIT 3 |
Functions | |
uint_fast32_t | makeQualifiedFileName (char *fileName, uint_fast32_t fileNameLen, const char *componentName, const char *suffix, const char *dirName, uint_fast32_t flags) |
Create a filename and optionally qualify with the current date and process Id. More... | |
size_t | zeroFileContents (int descriptor, size_t fileLength) |
Write out zero-filled blocks to a file. More... | |
int | createMappedFile (unsigned char **segment, const char *fileName, size_t *segmentLenPtr, uint_fast32_t doInit) |
Create or open a mapped file with the specified file name. More... | |
int | expand_symlinks (char *resultPath, const uint_fast32_t bfrLen, const char *priorPath, uint_fast32_t priorLen, bool mustExist) |
Expand a path with symbolic links into its true name. More... | |
int | findFileInPath (char *resultFile, uint_fast32_t resultBfrLen, const char *desiredFile, const char *searchPath, const char *suffix="") |
Search for file under colon-separated path. More... | |
Utility functions to create and open memory-mapped files.
#define FILENAME_ADD_DIR_PREFIX 16 |
Unqualified filename should be prepended with default directory
#define FILENAME_WITH_DATE 1 |
Filename should be date-qualified
#define FILENAME_WITH_DATE_AND_PID 3 |
Filename should be date- and pid-qualified
#define FILENAME_WITH_DATE_AND_TIME 5 |
Filename should be date- and time-qualified
#define FILENAME_WITH_EVERYTHING ~0 |
Filename should be date-, time- and pid-qualified
#define FILENAME_WITH_HOST 8 |
Filename should be hostname-qualified
#define FILENAME_WITH_PID 2 |
Filename should be pid-qualified
#define FILENAME_WITH_TIME 4 |
Filename should be time-qualified
#define MAP_FILE_INIT 3 |
Initialize mapped file
#define MAP_FILE_READONLY 0 |
Mapped file is read-only
#define MAP_FILE_READWRITE 1 |
Mapped file is read/write
#define MAP_FILE_RESET 2 |
Reset mapped file
int createMappedFile | ( | unsigned char ** | segment, |
const char * | fileName, | ||
size_t * | segmentLenPtr, | ||
uint_fast32_t | doInit | ||
) |
Create or open a mapped file with the specified file name.
segment | is pointer to variable into which will be stored the base of the mapped segment. A value of 0 (which would represent a null pointer) will be returned on any error and is a portable way to detect the condition. |
fileName | specifies the name of the file to be opened/created. The file must exist unless the MAP_FILE_RESET bit is set in the doInit argument. |
segmentLenPtr | optionally points to a variable into which the segment length will be stored. If a null pointer or the existing value in the pointed-to variable is zero, the current length of the file will be used to determine the size of the segment. A value must be provided if a new file is being created. |
doInit | indicates how the segment should be prepared. MAP_FILE_INIT is used to create new segments or reinitialize an existing one. MAP_FILE_READONLY is used to obtain read-only access to an existing segment. MAP_FILE_READWRITE is used to obtain writeable-access to an existing segment while preserving its existing content. |
-1 | (POSIX) file could not be opened |
INVALID_HANDLE_VALUE | (Windows) file could not be opened |
References errno, flags, INVALID_HANDLE_VALUE, MAP_FILE_READWRITE, MAP_FILE_RESET, NULL, and zeroFileContents().
Referenced by createMappedVars(), SharedMemoryVariableManager::createSegment(), and MetaDataLoaderForFormat< RECORD_CLASS >::loadMetaDataHeader().
int expand_symlinks | ( | char * | resultPath, |
const uint_fast32_t | bfrLen, | ||
const char * | priorPath, | ||
uint_fast32_t | priorLen, | ||
bool | mustExist | ||
) |
Expand a path with symbolic links into its true name.
resultPath | points to the output buffer into which the result will be stored. Unlink realpath(), the result is not forced to be an absolute path name. |
bfrLen | indicates the size of the provided output buffer. |
priorPath | points to the path to be expanded; it does not have to be null-terminated. |
priorLen | indicates the length of the path to be expanded. |
mustExist | is a Boolean that indicates if all path components must reference directory entries that exist. |
resultPath
is returned. -1 | is returned if mustExist is true and a path element does not exist. The last path component present in resultPath does not exist. |
References MAX_PATH_ELEMENTS.
int findFileInPath | ( | char * | resultFile, |
uint_fast32_t | resultBfrLen, | ||
const char * | desiredFile, | ||
const char * | searchPath, | ||
const char * | suffix = "" |
||
) |
Search for file under colon-separated path.
resultFile | points to a buffer into which the name of the located file will be stored |
resultBfrLen | specifies the size of the provided buffer |
desiredFile | specifies the base element to be searched |
searchPath | specifies the colon-separated path elements to be searched |
suffix | specifies an optional suffix to be added to the end of the desiredFile element. |
resultFile
buffer. References F_OK.
uint_fast32_t makeQualifiedFileName | ( | char * | fileName, |
uint_fast32_t | fileNameLen, | ||
const char * | componentName, | ||
const char * | suffix, | ||
const char * | dirName, | ||
uint_fast32_t | flags | ||
) |
Create a filename and optionally qualify with the current date and process Id.
fileName | points to a buffer into which the constructed file name will be stored. |
fileNameLen | specifies the length of the fileName buffer. |
componentName | specifies the name of the component creating the file. |
suffix | specifies a suffix for the constructed file name, often something like ".log" or ".txt". |
dirName | specifies the directory in which the file should reside. |
flags | is a bit mask that specifies a combination of attributes that should be included in the filename. FILENAME_WITH_EVERYTHING includes all components whereas FILENAME_WITH_DATE would only include the current date. |
fileName
. References TimeAsDayAndYear::day, FILENAME_ADD_DIR_PREFIX, FILENAME_WITH_DATE, FILENAME_WITH_HOST, FILENAME_WITH_PID, FILENAME_WITH_TIME, flags, getTodaysDate(), TimeAsHourMinSec::hour, TimeAsHourMinSec::min, TimeAsDayAndYear::month, OME_EXPECT_TRUE, TimeAsHourMinSec::sec, and TimeAsDayAndYear::year.
Referenced by SharedMemoryVariableManager::createAndAttachStandardSegment().
size_t zeroFileContents | ( | int | descriptor, |
size_t | fileLength | ||
) |
Write out zero-filled blocks to a file.
descriptor | references a file already opened for write. |
fileLength | specifies the number of bytes to be written. |
References NULL.
Referenced by createMappedFile().
![]() | Generated: Tue Jul 28 2020 16:03:26
Support Information |