Hombre si es un program más sencillo que el mecanismo del chupete.
//#define __USE_LARGEFILE64
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
# define O_LARGEFILE 0100000
#define TAM_BUF
int main (int argc,char ** argv){
int i,n;
unsigned char buffer[TAM_BUF];
FILE *f;
int g;
printf ("Salida -> %s\n",argv[argc-1]);
g = open (argv[argc-1], O_RDWR | O_CREAT | O_LARGEFILE);
if (g<0){
fprintf( stderr, "No se pudo crear %s\n", argv[argc-1]);
exit( 1 );
}
for (i=1;i<(argc-1);i++){
printf ("Leyendo -> %s\n",argv[i]);
f = fopen (argv[i],"r");
if (f==NULL){
fprintf( stderr, "No se pudo abrir %s\n", argv[i]);
close (g);
exit( 1 );
}
n=fread (buffer,sizeof (unsigned char),TAM_BUF,f);
while (n>0){
//fwrite (buffer,sizeof (unsigned char),n,g);
if( write( g, buffer , n) < 0 )
{
//fprintf( stderr, "\nwrite() error\n" );
//fprintf( stderr, "error: %s\n",strerror(errno ) );
fprintf( stderr, "No se pudo escribir\n" );
close (g);
exit( 1 );
}
n=fread (buffer,sizeof (unsigned char),TAM_BUF,f);
}
fclose (f);
}
close (g);
}
No se que fallo puede haber hay.