CliXoN
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
clixon_file.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <regex.h>
#include <pwd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <unistd.h>
#include <netinet/in.h>
#include <cligen/cligen.h>
#include "clixon_err.h"
#include "clixon_queue.h"
#include "clixon_chunk.h"
#include "clixon_string.h"
#include "clixon_file.h"

Macros

#define __USE_GNU   /* strverscmp */
 

Functions

static int clicon_file_dirent_sort (const void *arg1, const void *arg2)
 
int clicon_file_dirent (const char *dir, struct dirent **ent, const char *regexp, mode_t type, const char *label)
 
char * clicon_tmpfile (const char *label)
 
int clicon_file_copy (char *src, char *target)
 

Macro Definition Documentation

#define __USE_GNU   /* strverscmp */

Function Documentation

int clicon_file_copy ( char *  src,
char *  target 
)

Make a copy of file src

Return values
0OK
-1Error
int clicon_file_dirent ( const char *  dir,
struct dirent **  ent,
const char *  regexp,
mode_t  type,
const char *  label 
)

Return sorted matching files from a directory

Parameters
[in]dirDirectory path
[out]entEntries pointer, will be filled in with dir entries
[in]regexpRegexp filename matching
[in]typeFile type matching, see stat(2)
[in]labelClicon Chunk label for memory handling, unchunk after use
Return values
nNumber of matching files in directory
-1Error
char *dir = "/root/fs";
struct dirent *dp;
if ((ndp = clicon_file_dirent(dir, &dp, "(.so)$", S_IFREG, __FUNCTION__)) < 0)
return -1;
for (i = 0; i < ndp; i++)
do something with dp[i].d_name;
unchunk_group(__FUNCTION__);
static int clicon_file_dirent_sort ( const void *  arg1,
const void *  arg2 
)
static
char* clicon_tmpfile ( const char *  label)