first commit
This commit is contained in:
commit
21be7fd279
156 changed files with 6939 additions and 0 deletions
39
include/libmu/get_stat.h
Normal file
39
include/libmu/get_stat.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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)) {
|
||||
if (prog_name != NULL)
|
||||
fprintf(stderr, "%s: %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)) {
|
||||
if (prog_name != NULL)
|
||||
fprintf(stderr, "%s: %s: %s\n", prog_name, path, strerror(errno));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mu_get_stats(const char *prog_name, int flag, const char *path, struct stat *stat_path) {
|
||||
if (flag)
|
||||
return mu_get_lstat(prog_name, path, stat_path);
|
||||
|
||||
else
|
||||
return mu_get_stat(prog_name, path, stat_path);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue