rpm  4.12.0.1
Files | Typedefs | Enumerations | Functions
File and Path Manipulation API.
Collaboration diagram for File and Path Manipulation API.:

Files

file  rpmfileutil.h
 File and path manipulation helper functions.
 

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
}
 

Functions

int rpmDoDigest (int algo, const char *fn, int asAscii, unsigned char *digest, rpm_loff_t *fsizep)
 Calculate a file digest and size. More...
 
FD_t rpmMkTemp (char *templ)
 Thin wrapper for mkstemp(3). More...
 
FD_t rpmMkTempFile (const char *prefix, char **fn)
 Return file handle for a temporaray file. More...
 
int rpmioMkpath (const char *path, mode_t mode, uid_t uid, gid_t gid)
 Insure that directories in path exist, creating as needed. More...
 
int rpmMkdirs (const char *root, const char *pathstr)
 Create several directories (including parents if needed) in one go. More...
 
char * rpmCleanPath (char *path)
 Canonicalize file path. More...
 
char * rpmGenPath (const char *urlroot, const char *urlmdir, const char *urlfile)
 Merge 3 args into path, any or all of which may be a url. More...
 
char * rpmGetPath (const char *path,...) RPM_GNUC_NULL_TERMINATED
 Return (malloc'ed) expanded, canonicalized, file path. More...
 
int rpmIsGlob (const char *pattern, int quote)
 Check whether pattern contains any glob metacharacters. More...
 
int rpmGlob (const char *patterns, int *argcPtr, ARGV_t *argvPtr)
 Return URL path(s) from a (URL prefixed) pattern glob. More...
 
char * rpmEscapeSpaces (const char *s)
 Escape isspace(3) characters in string. More...
 
int rpmFileIsCompressed (const char *file, rpmCompressedMagic *compressed)
 Return type of compression used in file. More...
 
int rpmFileHasSuffix (const char *path, const char *suffix)
 Check if path (string) ends with given suffix. More...
 
char * rpmGetCwd (void)
 Like getcwd() but the result is malloced. More...
 

Detailed Description

Typedef Documentation

Enumeration Type Documentation

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

Definition at line 20 of file rpmfileutil.h.

Function Documentation

char* rpmCleanPath ( char *  path)

Canonicalize file path.

Parameters
pathpath to canonicalize (in-place)
Returns
pointer to path
int rpmDoDigest ( int  algo,
const char *  fn,
int  asAscii,
unsigned char *  digest,
rpm_loff_t fsizep 
)

Calculate a file digest and size.

Parameters
algodigest algorithm
fnfile name
asAsciireturn digest as ascii string?
Return values
digestaddress of calculated digest
*fsizepfile size pointer (or NULL)
Returns
0 on success, 1 on error
char* rpmEscapeSpaces ( const char *  s)

Escape isspace(3) characters in string.

Parameters
sstring
Returns
escaped string
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
int rpmFileIsCompressed ( const char *  file,
rpmCompressedMagic compressed 
)

Return type of compression used in file.

Parameters
filename of file
Return values
compressedaddress of compression type
Returns
0 on success, 1 on I/O error
char* rpmGenPath ( const char *  urlroot,
const char *  urlmdir,
const char *  urlfile 
)

Merge 3 args into path, any or all of which may be a url.

The leading part of the first URL encountered is used for the result, other URL prefixes are discarded, permitting a primitive form of URL inheiritance.

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)

Referenced by buildForTarget().

char* rpmGetCwd ( void  )

Like getcwd() but the result is malloced.

Returns
current working directory (malloc'ed)

Referenced by buildForTarget().

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)

Referenced by getTarSpec().

int rpmGlob ( const char *  patterns,
int *  argcPtr,
ARGV_t argvPtr 
)

Return URL path(s) from a (URL prefixed) pattern glob.

Parameters
patternsglob pattern
Return values
*argcPtrno. of paths
*argvPtrARGV_t array of paths
Returns
0 on success
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
int rpmIsGlob ( const char *  pattern,
int  quote 
)

Check whether pattern contains any glob metacharacters.

Parameters
patternglob pattern
quoteallow backslash quoting of metacharacters?
Returns
1 if pattern contains globs, 0 otherwise
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

Referenced by buildForTarget().

FD_t rpmMkTemp ( char *  templ)

Thin wrapper for mkstemp(3).

Parameters
templtemplate for temporary filename
Returns
file handle or NULL on error
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
Return values
fntemp file name (or NULL)
Returns
fdptr open file handle or NULL on error