forked from Arachne-Labs/Prometheus-QoS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
41 lines (38 loc) · 621 Bytes
/
utils.c
File metadata and controls
41 lines (38 loc) · 621 Bytes
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
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
/* http://stackoverflow.com/questions/4021479/getting-file-modification-time-on-unix-using-utime-in-c */
time_t get_mtime(const char *path)
{
struct stat statbuf;
if (stat(path, &statbuf) == -1)
{
perror(path);
exit(1);
}
return statbuf.st_mtime;
}
/* just text line parsing */
char *parse_datafile_line(char *str)
{
char *ptr = strchr(str,' ');
if(!ptr)
{
ptr = strchr(str,'\t');
}
if(ptr)
{
*ptr = 0;
ptr++;
while(*ptr == ' ' || *ptr == '\t')
{
ptr++;
}
return ptr;
}
else
{
return NULL;
}
}