rpm 6.1.90
The RPM Package Manager
Loading...
Searching...
No Matches
File and Path Manipulation API.

File and path manipulation helper functions. More...

Collaboration diagram for File and Path Manipulation API.:

Files

file  rpmfileutil.h

Typedefs

typedef enum rpmCompressedMagic_e rpmCompressedMagic

Enumerations

enum  rpmCompressedMagic_e {
  COMPRESSED_NOT = 0 , COMPRESSED_OTHER = 1 , COMPRESSED_BZIP2 = 2 , COMPRESSED_ZIP = 3 ,
  COMPRESSED_LZMA = 4 , COMPRESSED_XZ = 5 , COMPRESSED_LZIP = 6 , COMPRESSED_LRZIP = 7 ,
  COMPRESSED_7ZIP = 8 , COMPRESSED_GEM = 9 , COMPRESSED_ZSTD = 10 , COMPRESSED_CAR = 11
}
enum  rpmglobFlags_e { RPMGLOB_NONE = 0 , RPMGLOB_NOCHECK = (1 << 0) }

Functions

RPM_PUBLIC_API int rpmDoDigest (int algo, const char *fn, int asAscii, unsigned char *digest)
RPM_PUBLIC_API FD_t rpmMkTemp (char *templ)
RPM_PUBLIC_API FD_t rpmMkTempFile (const char *prefix, char **fn)
RPM_PUBLIC_API int rpmioMkpath (const char *path, mode_t mode, uid_t uid, gid_t gid)
RPM_PUBLIC_API int rpmMkdirs (const char *root, const char *pathstr)
RPM_PUBLIC_API char * rpmCleanPath (char *path)
RPM_PUBLIC_API char * rpmGenPath (const char *urlroot, const char *urlmdir, const char *urlfile)
RPM_PUBLIC_API char * rpmGetPath (const char *path,...) RPM_GNUC_NULL_TERMINATED
RPM_PUBLIC_API int rpmGlobPath (const char *pattern, rpmglobFlags flags, int *argcPtr, ARGV_t *argvPtr)
RPM_PUBLIC_API int rpmGlob (const char *pattern, int *argcPtr, ARGV_t *argvPtr)
RPM_PUBLIC_API char * rpmEscapeSpaces (const char *s)
RPM_PUBLIC_API char * rpmEscape (const char *s, const char *accept)
RPM_PUBLIC_API void rpmUnescape (char *s, const char *accept)
RPM_PUBLIC_API int rpmFileIsCompressed (const char *file, rpmCompressedMagic *compressed)
RPM_PUBLIC_API int rpmFileHasSuffix (const char *path, const char *suffix)
RPM_PUBLIC_API char * rpmGetCwd (void)

Detailed Description

File and path manipulation helper functions.

Typedef Documentation

◆ rpmCompressedMagic

Compression types detected by rpm (subject to build configuration).

Enumeration Type Documentation

◆ rpmCompressedMagic_e

Compression types detected by rpm (subject to build configuration).

Enumerator
COMPRESSED_NOT 

not compressed

COMPRESSED_OTHER 

gzip can handle

COMPRESSED_BZIP2 

bzip2 can handle

COMPRESSED_ZIP 

unzip can handle

COMPRESSED_LZMA 

lzma can handle

COMPRESSED_XZ 

xz can handle

COMPRESSED_LZIP 

lzip can handle

COMPRESSED_LRZIP 

lrzip can handle

COMPRESSED_7ZIP 

7zip can handle

COMPRESSED_GEM 

gem can handle

COMPRESSED_ZSTD 

zstd can handle

COMPRESSED_CAR 

car can handle

◆ rpmglobFlags_e

RPM glob flags, largely modelled after glob(3) flags.

Enumerator
RPMGLOB_NOCHECK 

same as GLOB_NOCHECK

Function Documentation

◆ rpmCleanPath()

RPM_PUBLIC_API char * rpmCleanPath ( char * path)

Canonicalize file path.

Parameters
pathpath to canonicalize (in-place)
Returns
pointer to path

◆ rpmDoDigest()

RPM_PUBLIC_API int rpmDoDigest ( int algo,
const char * fn,
int asAscii,
unsigned char * digest )

Calculate a file digest and size.

Parameters
algodigest algorithm
fnfile name
asAsciireturn digest as ascii string?
[out]digestaddress of calculated digest
Returns
0 on success, 1 on error

◆ rpmEscape()

RPM_PUBLIC_API char * rpmEscape ( const char * s,
const char * accept )

Escape given characters in string.

Parameters
sstring
acceptchars to escape
Returns
escaped string

◆ rpmEscapeSpaces()

RPM_PUBLIC_API char * rpmEscapeSpaces ( const char * s)

Escape isspace(3) characters in string.

Parameters
sstring
Returns
escaped string

◆ rpmFileHasSuffix()

RPM_PUBLIC_API int rpmFileHasSuffix ( const char * path,
const char * suffix )

Check if path (string) ends with given suffix

Parameters
path(path) string
suffixsuffix string to check for
Returns
1 if true, 0 otherwise

◆ rpmFileIsCompressed()

RPM_PUBLIC_API int rpmFileIsCompressed ( const char * file,
rpmCompressedMagic * compressed )

Return type of compression used in file.

Parameters
filename of file
[out]compressedaddress of compression type
Returns
0 on success, 1 on I/O error

◆ rpmGenPath()

RPM_PUBLIC_API char * rpmGenPath ( const char * urlroot,
const char * urlmdir,
const char * urlfile )

Merge 3 args into path. Contrary to what the argument names and older API docs claim, THIS DOES NOT HANDLE URL's.

Parameters
urlrootroot URL (often path to chroot, or NULL)
urlmdirdirectory URL (often a directory, or NULL)
urlfilefile URL (often a file, or NULL)
Returns
expanded, merged, canonicalized path (malloc'ed)

◆ rpmGetCwd()

RPM_PUBLIC_API char * rpmGetCwd ( void )

Like getcwd() but the result is malloced.

Returns
current working directory (malloc'ed)

◆ rpmGetPath()

RPM_PUBLIC_API char * rpmGetPath ( const char * path,
... )

Return (malloc'ed) expanded, canonicalized, file path.

Parameters
pathmacro(s) to expand (NULL terminates list)
Returns
canonicalized path (malloc'ed)

◆ rpmGlob()

RPM_PUBLIC_API int rpmGlob ( const char * pattern,
int * argcPtr,
ARGV_t * argvPtr )

Expand a glob pattern into matching paths, fail if nothing matches.

Parameters
patternglob pattern
[out]*argcPtrno. of paths
[out]*argvPtrARGV_t array of paths
Returns
0 on success

◆ rpmGlobPath()

RPM_PUBLIC_API int rpmGlobPath ( const char * pattern,
rpmglobFlags flags,
int * argcPtr,
ARGV_t * argvPtr )

Expand a glob pattern into matching paths. When RPMGLOB_NOCHECK is specified, non-matching and non-glob patterns are returned as is.

Parameters
patternglob pattern
flagsbit(s) to control glob operation
[out]*argcPtrno. of paths
[out]*argvPtrARGV_t array of paths
Returns
0 on success

◆ rpmioMkpath()

RPM_PUBLIC_API int rpmioMkpath ( const char * path,
mode_t mode,
uid_t uid,
gid_t gid )

Insure that directories in path exist, creating as needed.

Parameters
pathdirectory path
modedirectory mode (if created)
uiddirectory uid (if created), or -1 to skip
giddirectory uid (if created), or -1 to skip
Returns
0 on success, errno (or -1) on error

◆ rpmMkdirs()

RPM_PUBLIC_API int rpmMkdirs ( const char * root,
const char * pathstr )

Create several directories (including parents if needed) in one go. Macros in pathstr will be expanded in the process.

Parameters
rootleading root directory (or NULL for none)
pathstrlist of directories separated with :
Returns
0 if all directories were successfully created (or already existed), non-zero otherwise

◆ rpmMkTemp()

RPM_PUBLIC_API FD_t rpmMkTemp ( char * templ)

Thin wrapper for mkstemp(3).

Parameters
templtemplate for temporary filename
Returns
file handle or NULL on error

◆ rpmMkTempFile()

RPM_PUBLIC_API FD_t rpmMkTempFile ( const char * prefix,
char ** fn )

Return file handle for a temporaray file. A unique temporaray file path will be created in [prefix/]%{_tmppath} directory. The file name and the open file handle are returned.

Parameters
prefixleading part of temp file path
[out]fntemp file name (or NULL)
Returns
fdptr open file handle or NULL on error

◆ rpmUnescape()

RPM_PUBLIC_API void rpmUnescape ( char * s,
const char * accept )

Unescape each char listed in accept by removing a backslash preceding it.

Parameters
sstring
acceptchars to unescape (NULL for all)