Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char ** initCheckArray(int deep);
- int checkArray(char** checkArray,char* linkToVerify,int deep);
- void debugArray(char** testArray,int deep);
- void checkFic(int number,char* name,char* versionName);
- void giveRepoName(char *name);
- void giveRepoName(char *name){
- time_t secondes;
- struct tm instant;
- int year,day,month;
- char strYear[12];
- char strMonth[12];
- char strDay[12];
- char *repoName = malloc(sizeof(char)*strlen(name)+8);
- time(&secondes);
- instant=*localtime(&secondes);
- year = instant.tm_year+1900;
- month = instant.tm_mon+1;
- day = instant.tm_mday;
- printf("Year : %d , Month : %d , day : %d\n",year,month,day);
- strcpy(repoName,name);
- sprintf(strYear, "%d", year);
- strcat(repoName,strYear);
- sprintf(strMonth, "%d", month);
- strcat(repoName,strMonth);
- sprintf(strDay, "%d", day);
- strcat(repoName,strDay);
- printf("Repo name : %s",repoName);
- checkFic(0,repoName,repoName);
- }
- void checkFic(int number,char* name,char* versionName){
- int dossierValid;
- char strVersion[5];
- char* dossier = malloc(sizeof(char)*100);
- char *path = malloc(sizeof(char)*100);
- strcpy(path,"C:\\Users\\mathi\\Desktop\\");
- strcpy(dossier,path);
- strcat(dossier,versionName);
- puts(access(dossier, 0) ? "Absent" : "Present");
- dossierValid = access(dossier, 0);
- if (dossierValid != 0){
- mkdir(dossier);
- }else{
- printf("Le dossier existe deja");
- strcpy(versionName,name);
- strcat(versionName,"-");
- number++;
- sprintf(strVersion, "%d", number);
- strcat(versionName,strVersion);
- printf("\nNouveau nom : %s",versionName);
- checkFic(number,name,versionName);
- }
- }
- char ** initCheckArray(int deep){
- int i;
- char ** newArray = malloc(sizeof(char)*deep);
- for(i = 0 ; i <= deep ; i++){
- newArray[i] = malloc(sizeof(char)*200);
- strcpy(newArray[i],"empty");
- }
- return newArray;
- }
- int checkArray(char** checkArray,char* linkToVerify,int deep){
- int i;
- for(i = 0 ; i < deep ; i++){
- if(strcmp(checkArray[i],linkToVerify)==0){
- return 0;
- }
- }
- for(i = 0 ; i < deep ; i++){
- if(strcmp(checkArray[i],"empty")==0){
- strcpy(checkArray[i],linkToVerify);
- return 1;
- }
- }
- return 2;
- }
- void debugArray(char** testArray,int deep){
- int i;
- printf("\n\n\n\n");
- printf("Verif size : %d",deep);
- for(i = 0 ; i < deep ; i++){
- printf("\n Debug array[%d] : %s",i,testArray[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement