/* stat.c */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int compara ( const char *file1, const char *file2 )
{
struct stat f1, f2;
if ( stat ( file1, &f1 ) == -1 ) exit ( EXIT_FAILURE );
if ( stat ( file2, &f2 ) == -1 ) exit ( EXIT_FAILURE );
return ( f1.st_size - f2.st_size );
}
int main ( int argc, char **argv )
{
int n;
if ( argc < 3 )
{
printf ( "Usage: %s [file1] [file2]\n", argv[0] );
return EXIT_FAILURE;
}
n = compara ( argv[1], argv[2] );
if ( n > 0 ) printf ( "%s maior\n", argv[1] );
else if ( n < 0 ) printf ( "%s maior\n", argv[2] );
else printf ( "IGUAL\n" );
return EXIT_SUCCESS;
}
/* EoF */