File and path manipulation helper functions.  
More...
|  | 
| 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
 }
 | 
|  | 
|  | 
| int | rpmDoDigest (int algo, const char *fn, int asAscii, unsigned char *digest) | 
|  | 
| FD_t | rpmMkTemp (char *templ) | 
|  | 
| FD_t | rpmMkTempFile (const char *prefix, char **fn) | 
|  | 
| int | rpmioMkpath (const char *path, mode_t mode, uid_t uid, gid_t gid) | 
|  | 
| int | rpmMkdirs (const char *root, const char *pathstr) | 
|  | 
| char * | rpmCleanPath (char *path) | 
|  | 
| char * | rpmGenPath (const char *urlroot, const char *urlmdir, const char *urlfile) | 
|  | 
| char * | rpmGetPath (const char *path,...) RPM_GNUC_NULL_TERMINATED | 
|  | 
| int | rpmIsGlob (const char *pattern, int quote) | 
|  | 
| int | rpmGlob (const char *patterns, int *argcPtr, ARGV_t *argvPtr) | 
|  | 
| char * | rpmEscapeSpaces (const char *s) | 
|  | 
| int | rpmFileIsCompressed (const char *file, rpmCompressedMagic *compressed) | 
|  | 
| int | rpmFileHasSuffix (const char *path, const char *suffix) | 
|  | 
| char * | rpmGetCwd (void) | 
|  | 
File and path manipulation helper functions. 
◆ rpmCompressedMagic
◆ rpmCompressedMagic_e
| 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  | 
Definition at line 20 of file rpmfileutil.h.
 
 
◆ rpmCleanPath()
      
        
          | char* rpmCleanPath | ( | char * | path | ) |  | 
      
 
Canonicalize file path. 
- Parameters
- 
  
    | path | path to canonicalize (in-place) |  
 
- Returns
- pointer to path 
 
 
◆ rpmDoDigest()
      
        
          | int rpmDoDigest | ( | int | algo, | 
        
          |  |  | const char * | fn, | 
        
          |  |  | int | asAscii, | 
        
          |  |  | unsigned char * | digest | 
        
          |  | ) |  |  | 
      
 
Calculate a file digest and size. 
- Parameters
- 
  
    | algo | digest algorithm |  | fn | file name |  | asAscii | return digest as ascii string? |  
 
- Return values
- 
  
    | digest | address of calculated digest |  
 
- Returns
- 0 on success, 1 on error 
 
 
◆ rpmEscapeSpaces()
      
        
          | char* rpmEscapeSpaces | ( | const char * | s | ) |  | 
      
 
Escape isspace(3) characters in string. 
- Parameters
- 
  
  
- Returns
- escaped string 
 
 
◆ rpmFileHasSuffix()
      
        
          | int rpmFileHasSuffix | ( | const char * | path, | 
        
          |  |  | const char * | suffix | 
        
          |  | ) |  |  | 
      
 
Check if path (string) ends with given suffix 
- Parameters
- 
  
    | path | (path) string |  | suffix | suffix string to check for |  
 
- Returns
- 1 if true, 0 otherwise 
 
 
◆ rpmFileIsCompressed()
Return type of compression used in file. 
- Parameters
- 
  
  
- Return values
- 
  
    | compressed | address of compression type |  
 
- Returns
- 0 on success, 1 on I/O error 
 
 
◆ rpmGenPath()
      
        
          | 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
- 
  
    | urlroot | root URL (often path to chroot, or NULL) |  | urlmdir | directory URL (often a directory, or NULL) |  | urlfile | file URL (often a file, or NULL) |  
 
- Returns
- expanded, merged, canonicalized path (malloc'ed) 
 
 
◆ rpmGetCwd()
Like getcwd() but the result is malloced. 
- Returns
- current working directory (malloc'ed) 
 
 
◆ rpmGetPath()
      
        
          | char* rpmGetPath | ( | const char * | path, | 
        
          |  |  |  | ... | 
        
          |  | ) |  |  | 
      
 
Return (malloc'ed) expanded, canonicalized, file path. 
- Parameters
- 
  
    | path | macro(s) to expand (NULL terminates list) |  
 
- Returns
- canonicalized path (malloc'ed) 
 
 
◆ rpmGlob()
      
        
          | int rpmGlob | ( | const char * | patterns, | 
        
          |  |  | int * | argcPtr, | 
        
          |  |  | ARGV_t * | argvPtr | 
        
          |  | ) |  |  | 
      
 
Return URL path(s) from a (URL prefixed) pattern glob. 
- Parameters
- 
  
  
- Return values
- 
  
    | *argcPtr | no. of paths |  | *argvPtr | ARGV_t array of paths |  
 
- Returns
- 0 on success 
 
 
◆ rpmioMkpath()
      
        
          | int rpmioMkpath | ( | const char * | path, | 
        
          |  |  | mode_t | mode, | 
        
          |  |  | uid_t | uid, | 
        
          |  |  | gid_t | gid | 
        
          |  | ) |  |  | 
      
 
Insure that directories in path exist, creating as needed. 
- Parameters
- 
  
    | path | directory path |  | mode | directory mode (if created) |  | uid | directory uid (if created), or -1 to skip |  | gid | directory uid (if created), or -1 to skip |  
 
- Returns
- 0 on success, errno (or -1) on error 
 
 
◆ rpmIsGlob()
      
        
          | int rpmIsGlob | ( | const char * | pattern, | 
        
          |  |  | int | quote | 
        
          |  | ) |  |  | 
      
 
Check whether pattern contains any glob metacharacters. 
- Parameters
- 
  
    | pattern | glob pattern |  | quote | allow backslash quoting of metacharacters? |  
 
- Returns
- 1 if pattern contains globs, 0 otherwise 
 
 
◆ rpmMkdirs()
      
        
          | 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
- 
  
    | root | leading root directory (or NULL for none) |  | pathstr | list of directories separated with : |  
 
- Returns
- 0 if all directories were successfully created (or already existed), non-zero otherwise 
 
 
◆ rpmMkTemp()
      
        
          | FD_t rpmMkTemp | ( | char * | templ | ) |  | 
      
 
Thin wrapper for mkstemp(3). 
- Parameters
- 
  
    | templ | template for temporary filename |  
 
- Returns
- file handle or NULL on error 
 
 
◆ rpmMkTempFile()
      
        
          | 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
- 
  
    | prefix | leading part of temp file path |  
 
- Return values
- 
  
    | fn | temp file name (or NULL) |  
 
- Returns
- fdptr open file handle or NULL on error