added cli_filecopy()

git-svn: trunk@1206
remotes/push_mirror/metadata
Tomasz Kojm 21 years ago
parent 75ccac9f29
commit b067a7dd54
  1. 4
      clamav-devel/ChangeLog
  2. 30
      clamav-devel/libclamav/others.c
  3. 1
      clamav-devel/libclamav/others.h

@ -1,3 +1,7 @@
Mon Dec 20 02:57:29 CET 2004 (tk)
---------------------------------
* libclamav/others.c: added cli_filecopy()
Mon Dec 20 02:32:30 CET 2004 (tk)
---------------------------------
* improved OS/2 support (thanks to Yuri Dario <mc6530*mclink.it>)

@ -66,6 +66,10 @@ pthread_mutex_t cli_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER;
# endif
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#define CL_FLEVEL 3 /* don't touch it */
#define MAX_ALLOCATION 134217728
@ -574,3 +578,29 @@ int cli_memstr(const char *haystack, int hs, const char *needle, int ns)
return 0;
}
int cli_filecopy(const char *src, const char *dest)
{
char *buffer;
int s, d, bytes;
if((s = open(src, O_RDONLY)) == -1)
return -1;
if((d = open(dest, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY)) == -1) {
close(s);
return -1;
}
if(!(buffer = cli_malloc(FILEBUFF)))
return -1;
while((bytes = cli_readn(s, buffer, FILEBUFF)) > 0)
cli_writen(d, buffer, bytes);
free(buffer);
close(s);
return close(d);
}

@ -38,5 +38,6 @@ int32_t cli_readint32(const char *buff);
char *cli_gentemp(const char *dir);
unsigned int cli_rndnum(unsigned int max);
int cli_memstr(const char *haystack, int hs, const char *needle, int ns);
int cli_filecopy(const char *src, const char *dest);
#endif

Loading…
Cancel
Save