mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-07 04:16:26 +02:00
Minor changes
This commit is contained in:
parent
c5ca719d68
commit
c06d284b70
2 changed files with 14 additions and 1 deletions
10
src/utils.c
10
src/utils.c
|
@ -4,4 +4,14 @@ void mkdirp(char *path){
|
||||||
char buffer[255]="mkdir -p ";
|
char buffer[255]="mkdir -p ";
|
||||||
strcat(buffer,path);
|
strcat(buffer,path);
|
||||||
system(buffer);
|
system(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char dir_exists(char *path){
|
||||||
|
DIR* dir = opendir(path);
|
||||||
|
if (dir) {
|
||||||
|
/* Directory exists. */
|
||||||
|
closedir(dir);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#define MIN_INTERVAL 30
|
#define MIN_INTERVAL 30
|
||||||
#define INA260_SYSFS "/sys/kernel/ina260"
|
#define INA260_SYSFS "/sys/kernel/ina260"
|
||||||
|
@ -28,5 +29,7 @@
|
||||||
#define INTERVAL_LAST(duration)\
|
#define INTERVAL_LAST(duration)\
|
||||||
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
|
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
|
||||||
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
|
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
|
||||||
|
#define DIR_EXISTS(path) (dir_exists(path))
|
||||||
|
|
||||||
void mkdirp(char *path);
|
void mkdirp(char *path);
|
||||||
|
unsigned char dir_exists(char *path);
|
Loading…
Add table
Reference in a new issue