summaryrefslogtreecommitdiff
path: root/src/utils.c
blob: 80149d53168a598c7587f90b71ee35fff580dfef (plain)
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
#include "utils.h"
#include <stdio.h>
#include <unistd.h>

void mkdirp(char *path){
    char buffer[255]="mkdir -p ";
    strcat(buffer,path);
    system(buffer);
}

unsigned char dir_exists(char *path){
    DIR* dir = opendir(path);
    if (dir) {
        /* Directory exists. */
        closedir(dir);
        return 1;
    }
    return 0;
}

void askforbreak(char *break_file){
  FILE * file;
  file = fopen(break_file, "r");
  while(file){
    printf("I am doing a break for %ds\n", BREAK_DURATION);
    sleep(BREAK_DURATION);
    fclose(file);
    file = fopen(break_file, "r");
  }
}