Ver Mensaje Individual
  #15 (permalink)  
Antiguo 26/10/2006, 05:54
Avatar de Eternal Idol
Eternal Idol
 
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años, 9 meses
Puntos: 74
Unos minimos retoques y funciona en Windows, compilado con VC++ que se quejaba sobre tu problema, d:\src\posix.cpp(27) : warning C4700: local variable 'ultimo' used without havin
g been initialized

Código:
#include <windows.h>
extern "C" open(char*, unsigned long);
extern "C" close(int);

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>

int main (int argc, char * argv[])
{
	struct stat estado;
	time_t ultimo;
	int fd, i;
	printf("\n Fichero a comprobar %s", argv[1]);

	fd = open(argv[1], O_RDONLY);
	fstat(fd, &estado);
	ultimo = estado.st_mtime;
	close(fd);

	for(i=0;i<3;i++)
	{
		fd = open(argv[1],O_RDONLY);
		fstat(fd,&estado);
		if(estado.st_mtime != ultimo)
		{
			ultimo = estado.st_mtime;
			printf("\n- El archivo %s ha sido modificado", argv[1]);
		}
		else
		{
			printf("\n- El archivo %s no ha sido modificado", argv[1]);
		}
		Sleep(10 * 1000);
		i = 0;
		close(fd);
	}
	return 0;
}
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO