Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void rotate() {
- fclose(filelogs);
- char tmp[100];
- strcpy(tmp, fileName);
- int count = 0;
- while(access(tmp, F_OK) == 0) {
- count++;
- sprintf(tmp, "%s.%d", fileName, count);
- }
- for(int i = count; i > 0; i--){
- char newname[100], oldname[100];
- if(i==1){
- strcpy(oldname, fileName);
- }
- else{
- sprintf(oldname, "%s.%d", fileName, i-1);
- }
- sprintf(newname, "%s.%d", fileName, i);
- rename(oldname, newname);
- }
- filelogs = fopen(fileName, "w");
- }
Advertisement
Add Comment
Please, Sign In to add comment