我是
靠谱客的博主
儒雅镜子,这篇文章主要介绍
cp_log,现在分享给大家,希望可以做个参考。
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <malloc.h>
#include <string.h>
#include <dirent.h>
#define DEBUG_LOG
#if defined(DEBUG_LOG)
#define DEBUG(fmt, arg...)
printf(fmt "rn", ##arg)
#else
#define DEBUG(fmt, arg...)
#endif
#define ERROR_LOG
#if defined(ERROR_LOG)
#define ERROR(fmt, arg...)
printf("ERROR" fmt "rn", ##arg)
#else
#define ERROR(fmt, arg...)
#endif
#define FNAME_MAXLEN 10000
#define UNDERSCORE 1
#define SLASH 2
int isdir(char *path)
{
struct stat buf;
if (lstat(path, &buf) < 0)
DEBUG("Error: isdir lstat error!n");
if (S_ISDIR(buf.st_mode))
{
//DEBUG("Is a direcotry!n");
return 1;
}
else
return 0;
}
int isreg(char *path)
{
struct stat buf;
if (lstat(path, &buf) < 0)
DEBUG("Error: isreg lstat error!n");
if (S_ISREG(buf.st_mode))
{
//DEBUG("Is a direcotry!n");
return 1;
}
else
return 0;
}
int connect_symbol(char *first, char *sec, char val)
{
char temp[3] ;
if (val == 1)
temp[0] = '_';
else if (val == 2)
temp[0] = '/';
else
printf("connect_symbol: Error!n");
temp[1] = '