
Simular un trigger ante la presencia de un archivo
C/Visual C
Publicado el 9 de Marzo del 2023 por Elvinofalta
348 visualizaciones desde el 9 de Marzo del 2023
Si el Archivo se genera despues de las 17:30 el programa finaliza, o podrias agregarle que envie un mail o disparando un proceso etc etc etc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
*************************************************************
* @file gocheck.c
* Compilacion: cc -c gocheck.c -o gocheck.o -w
* LinkEdicion: cc -o gocheck gocheck.o -w
* ***********************************************
* Comp&Linker:
cc -o gocheck gocheck.c
* autor: ElVino.Falta(farfan890@gmail.com)
* @brief detecta la fecha de una archivo
*************************************************************
*/
#include <time.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#define TRUE 1
#define FALSE 0
int main( int argc, char* argv[] ) {
char file[] = "ArvhivodeHoy.txt";
char tmFile[ 100 ] = "";
char tmFile_Fecha[ 10 ] = "";
char tmFile_Hora[ 6 ] = "";
char tmHoy[ 100 ] = "";
char tmHoy_Fecha[ 10 ] = "";
char tmHoy_Hora[ 6 ] = "";
struct stat b;
time_t tToday = time(NULL);
/*
strftime(tmHoy, 100, "%d/%m/%Y %H:%M:%S", localtime( &tToday));
strftime(tmHoy_Fecha, 10, "%Y%m%d ", localtime( &tToday));
strftime(tmHoy_Hora, 6, "%H%M", localtime( &tToday));
printf("\nFecha y Hora, Hoy = %s\n", tmHoy);
printf("\nFecha %s y Hora %s de Hoy\n", tmHoy_Fecha, tmHoy_Hora);
*/
while(TRUE) {
tToday = time(NULL);
strftime(tmHoy, 100, "%d/%m/%Y %H:%M:%S", localtime( &tToday));
strftime(tmHoy_Fecha, 10, "%Y%m%d ", localtime( &tToday));
strftime(tmHoy_Hora, 6, "%H%M", localtime( &tToday));
printf("\nFecha y Hora, Hoy = %s\n", tmHoy);
printf("\nFecha %s y Hora %s de Hoy\n", tmHoy_Fecha, tmHoy_Hora);
if (!stat(file, &b)) {
strftime(tmFile, 100, "%d/%m/%Y %H:%M:%S", localtime( &b.st_mtime));
strftime(tmFile_Fecha, 10, "%Y%m%d ", localtime( &b.st_mtime));
strftime(tmFile_Hora, 6, "%H%M", localtime( &b.st_mtime));
printf("\nUltima Modificacion = %s\n", tmFile);
printf("\nFecha %s y Hora %s del Archivo\n", tmFile_Fecha, tmFile_Hora);
if( strcmp(tmHoy_Fecha, tmFile_Fecha) == 0) {
printf("\nEl Archivo tiene fecha de Hoy... %s\n", tmFile_Fecha);
if (atoi(tmFile_Hora) > 1730) {
printf("\nY se genero despues de la 17:30 %s\n", tmFile_Hora);
break;
} else
printf("\nY es anterior a las 17:30 %s \n", tmFile_Hora);
}
} else {
printf("No existe aun el Archivo\n");
}
sleep(5);
}
return 0;
}