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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
int main(int argc, char *argv[])
{
/* Déclarations */
HANDLE hEnt;
WIN32_FIND_DATA ent;
char chemin_site_HYE[]="Hye\\";
char chemin_site_DA[]="Da\\";
char chemin_mois_1[]="1\\";
char chemin_mois_2[]="2\\";
char chemin_mois_3[]="3\\";
char chemin_mois_4[]="4\\";
char chemin_mois_5[]="5\\";
char chemin_mois_6[]="6\\";
char chemin_mois_7[]="7\\";
char chemin_mois_8[]="8\\";
char chemin_mois_9[]="9\\";
char chemin_mois_10[]="10\\";
char chemin_mois_11[]="11\\";
char chemin_mois_12[]="12\\";
char chemin_annee_2007[]="2007\\";
char chemin_annee_2008[]="2008\\";
char chemin_annee_2009[]="2009\\";
char chemin_annee_2010[]="2010\\";
char chemin_source_9[]="F:\\donnees\\goniometrie\\courts\\";
char chemin_destination[100];
int i=0,j=0,k=0,l=2,chiffre;
char site[50], annee[5], mois[3], date[50], heure[50], extension[50], utilisateur[3];
char recup [3][50];
char lpBuffer[100], nom_fichier_copie[100], separators[] = "_.\n", *p;
printf(« Tapez gc\n ») ;
scanf(« %s,utilisateur) ; /* Le fait de faire taper à l'utilisateur gc,détermine directement l'arborescence ou l'on doit lister et copier les fichiers */
if (strcmp (utilisateur, "gc")==0)
{
printf("\nVous avez choisi des donnees goniometriques courts \n\n\n");
if ((hEnt = FindFirstFile("F:\\donnees\\goniometrie\\courts\\*.*", &ent)) != INVALID_HANDLE_VALUE)
{
do
{
printf("%s\n", ent.cFileName);
strcpy(lpBuffer,ent.cFileName);
p = strtok(lpBuffer, separators);
printf("\n\nAffichage des sous chaines avec strtok\n\n");
i=0;
while(p != NULL)
{
strcpy(recup[i],p);
printf("%s\n", p);
i++;
p = strtok(NULL, separators);
}
strcpy(site,recup[0]);
strcpy(date,recup[1]);
strcpy(heure,recup[2]);
strcpy(extension,recup[3]);
/* Partie decoupage date en mois et annee */
for(k=0;k<4;k++)
{
annee[k]=date[k];
}
annee[4]='\0';
for (k=4, j=0; k<6; k++, j++)
{
mois[j]=date[k];
}
mois[2]='\0';
printf("\n\nsite : %s\n",site);
printf("extension : %s\n",extension);
printf("mois : %s\n",mois);
printf("annee : %s\n",annee);
printf("\n\n\n");
/* Ajout de conditions pour déterminer larborescence de copie ! Ca marche niquel ! */
char chemin_destination[]="G:\\executable\\SERVEUR\\goniometrie\\courts\\";
if (strcmp(annee,"2008")==0)
{
strcat(chemin_destination,chemin_annee_2008);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
if (strcmp(annee,"2009")==0)
{
strcat(chemin_destination,chemin_annee_2009);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
if (strcmp(mois,"09")==0)
{
strcat(chemin_destination,chemin_mois_9);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
if (strcmp(mois,"12")==0)
{
strcat(chemin_destination,chemin_mois_12);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
if (strcmp(site,"HYE")==0)
{
strcat(chemin_destination,chemin_site_HYE);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
if (strcmp(site,"DAK")==0)
{
strcat(chemin_destination,chemin_site_DAK);
printf("\nevoltion chemin destination : %s\n",chemin_destination);
}
/* la partie la plus delicate, la chaine chemin_source_9 :( */
CopyFile(chemin_destination,chemin_source_9,0);
}
while (FindNextFile(hEnt, &ent));
FindClose(hEnt);
} |