/* * C_lib Copyright (C) 2022 Wael Karram. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* This header defines various file utility functions. */ #ifndef FILE_UTILS_H #define FILE_UTILS_H /* Include unistd.h (for access). */ #include /* Include sys/types and sys/stat to check type. */ #include #include /* Define constants. */ #define PASS_FAIL_FILE_UTILS_H -1 #define TRUE_FILE_UTILS_H 1 #define FALSE_FILE_UTILS_H 2 /* Set debug if needed. */ #ifdef DEBUG #ifndef NDEBUG #define NDEBUG #endif /* NDEBUG */ #endif /* DEBUG */ /* Include assert.h to allow code generation. */ #include /* This function checks if a file or directory exists at the given path. */ static inline int check_file_exists(const char *path); /* This function checks if the path points to a file or directory, assumes existence! */ static inline int check_if_file(const char *path); /* This function checks if the path exists and points to a directory. */ static inline int check_if_directory_exists(const char *path); /* This function checks if the path exists and points to a file. */ static inline int check_if_file_exists(const char *path); #endif /* FILE_UTILS_H */