
		elgio
		
		(usa Debian)
		
		Enviado em 03/04/2008 - 09:31h 
		/* CODIGO FONTE */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
	int i;
	struct stat s;
	if (argc < 2){
		fprintf(stderr, "ERRO: faltou parametro\n");
		return(1);
	}
	for (i = 1; i< argc; i++){
		if (stat(argv[i], &s)){
			fprintf(stderr, "ERRO ao tentar obter stat de %s\n", argv[i]);
			continue;
		}
		printf("===> %s\n", argv[i]);
		printf("\tTamanho = %i\n", s.st_size);
		printf("\tUltimo acesso = %i\n", s.st_atime);
/* Outros campos, obtidos do man 2 stat :
st_dev      ID of device containing file 
st_ino      inode number 
st_mode     protection 
st_nlink    number of hard links 
st_uid      user ID of owner 
st_gid      group ID of owner
st_rdev     device ID (if special file)
st_size     total size, in bytes
st_blksize  blocksize for filesystem I/O
st_blocks   number of blocks allocated
st_atime    time of last access
st_mtime    time of last modification
st_ctime    time of last status change
*/
	}
}
/* TESTES:
$ make tamanho
cc     tamanho.c   -o tamanho
$ ./tamanho tamanho.c /etc/passwd /etc/shadow
===> tamanho.c
        Tamanho = 983
        Ultimo acesso = 1207225732
===> /etc/passwd
        Tamanho = 1547
        Ultimo acesso = 1207225591
===> /etc/shadow
        Tamanho = 1015
        Ultimo acesso = 1207224641
O tempo eh dado em SEGUNDOS. Tem funcao para converter, inclusive o date da linha de comando faz isto (testando para o tamanho.c):
$ date -d @1207225732
Qui Abr  3 09:28:52 BRT 2008