#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
#include <time.h>
#include <syslog.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <archive.h>
#include <archive_entry.h>
#include "util.h"
#include "log.h"
#include "package.h"
#include "alpm.h"
#include "alpm_list.h"
#include "md5.h"
#ifndef HAVE_STRSEP
char* strsep(char** str, const char* delims)
{
char* token;
if (*str==NULL) {
return NULL;
}
token=*str;
while (**str!='\0') {
if (strchr(delims,**str)!=NULL) {
**str='\0';
(*str)++;
return token;
}
(*str)++;
}
*str=NULL;
return token;
}
#endif
int _alpm_makepath(const char *path)
{
return(_alpm_makepath_mode(path, 0755));
}
int _alpm_makepath_mode(const char *path, mode_t mode)
{
char *orig, *str, *ptr, *incr;
mode_t oldmask = umask(0000);
int ret = 0;
orig = strdup(path);
incr = calloc(strlen(orig) + 1, sizeof(char));
str = orig;
while((ptr = strsep(&str, "/"))) {
if(strlen(ptr)) {
strcat(incr, "/");
strcat(incr, ptr);
if(access(incr, F_OK)) {
if(mkdir(incr, mode)) {
ret = 1;
break;
}
}
}
}
free(orig);
free(incr);
umask(oldmask);
return(ret);
}
#define CPBUFSIZE 8 * 1024
int _alpm_copyfile(const char *src, const char *dest)
|