(mc_stat, mc_lstat): define via macro.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-07-16 14:07:33 +03:00
parent b926c08ec9
commit 2124ffa498

View File

@ -542,47 +542,32 @@ mc_closedir (DIR * dirp)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int /* *INDENT-OFF* */
mc_stat (const vfs_path_t * vpath, struct stat *buf)
{
int result = -1;
const vfs_path_element_t *path_element;
if (vpath == NULL) #define MC_STATOP(name) \
return (-1); int mc_##name (const vfs_path_t *vpath, struct stat *buf) \
{ \
path_element = vfs_path_get_by_index (vpath, -1); int result = -1; \
if (vfs_path_element_valid (path_element)) const vfs_path_element_t *path_element; \
{ \
result = path_element->class->stat ? path_element->class->stat (vpath, buf) : -1; if (vpath == NULL) \
if (result == -1) return (-1); \
errno = path_element->class->name ? vfs_ferrno (path_element->class) : ENOTSUP; \
} path_element = vfs_path_get_by_index (vpath, -1); \
if (vfs_path_element_valid (path_element)) \
return result; { \
result = path_element->class->name ? path_element->class->name (vpath, buf) : -1; \
if (result == -1) \
errno = path_element->class->name ? vfs_ferrno (path_element->class) : ENOTSUP; \
} \
\
return result; \
} }
/* --------------------------------------------------------------------------------------------- */ MC_STATOP (stat)
MC_STATOP (lstat)
int /* *INDENT-ON* */
mc_lstat (const vfs_path_t * vpath, struct stat *buf)
{
int result = -1;
const vfs_path_element_t *path_element;
if (vpath == NULL)
return (-1);
path_element = vfs_path_get_by_index (vpath, -1);
if (vfs_path_element_valid (path_element))
{
result = path_element->class->lstat ? path_element->class->lstat (vpath, buf) : -1;
if (result == -1)
errno = path_element->class->name ? vfs_ferrno (path_element->class) : ENOTSUP;
}
return result;
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */