25 #include <sys/types.h>
85 const char *p = strrchr(src,
'/');
88 snprintf(
path,
sizeof(
path),
"%s/%s", dst, (p ? p + 1 : src));
93 if ((fd =
open(src, O_RDONLY)) < 0)
96 if ((fd2 =
open(dst, O_CREAT | O_TRUNC | O_WRONLY, sb.st_mode & 0777)) <
102 while ((len =
read(fd, buf,
sizeof(buf))) > 0) {
103 while ((len > 0) && (len2 =
write(fd2, buf, (
size_t)len)) >= 0)
121 if (remove(dst) < 0 ||
G_mkdir(dst) < 0)
141 snprintf(path2,
sizeof(path2),
"%s/%s", dst, dp->
d_name);
int G_recursive_copy(const char *src, const char *dst)
Copy recursively source directory to destination directory.
int G_lstat(const char *, struct stat *)
Get file status.
int G_mkdir(const char *)
Creates a new directory.
Header file for msvc/fcntl.c.
DIR * opendir(const char *name)
struct dirent * readdir(DIR *dir)