micro-utils/libmu/get_stat.h
Your Name 6d1cf79ca6 fix
2023-10-31 12:53:32 +03:00

28 lines
585 B
C

#ifndef _GET_STAT_H
#define _GET_STAT_H
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
int mu_get_stat(const char *prog_name, const char *path, struct stat *stat_path) {
if (stat(path, stat_path)) {
fprintf(stderr, "%s: unable to stat %s: %s\n", prog_name, path, strerror(errno));
return 1;
}
return 0;
}
int mu_get_lstat(const char *prog_name, const char *path, struct stat *stat_path) {
if (lstat(path, stat_path)) {
fprintf(stderr, "%s: unable to stat %s: %s\n", prog_name, path, strerror(errno));
return 1;
}
return 0;
}
#endif