Table of Contents

NAME

QccFilePathSearch, QccFilePathSearchOpenRead - searching operations for a filename in a path

SYNOPSIS

#include "libQccPack.h"

int QccFilePathSearch(const QccString pathlist, const QccString filename, QccString found_pathname);
FILE *QccFilePathSearchOpenRead(QccString filename, const char *environment_path_variable, const char *default_path_list);

DESCRIPTION

QccFilePathSearch() searches for a file named filename in the path specified by pathlist. pathlist is a string of directory names separated by colons, in a manner similar to that used by the $PATH environment variable in various shells. If the file is found in one of the specified directories, the full path to the file is returned in found_pathname. Additionally, QccFilePathSearch() returns 0. If the file is not found, QccFilePathSearch() returns 1, and found_pathname is set to the zero-length string. QccFilePathSearch() assumes that space is allocated for found_pathname prior to the function call.

QccFilePathSearchOpenRead() is similar to QccFilePathSearch() except that the path to use is retrieved from the environment variable specified by environment_path_variable, and the file, if found, is opened for reading. A FILE pointer to the opened file is returned. If the file is not found, QccFilePathSearchOpenRead() returns a NULL pointer. If the file is found, the full path to the found file is returned in filename, overwriting the original filename passed to the routine. If environment_path_variable is NULL, or the environment variable is not found in the environment, then default_path_list is used as the path in the search. If, in turn, default_path_list is NULL, then the current directory (i.e., a path of ".") is used as the search path.

SEE ALSO

QccFileOpen(3) , QccPack(3) , glob(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads