}
#endif // _di_f_file_is_at_
+#ifndef _di_f_file_is_stat_
+ f_status_t f_file_is_stat(const struct stat stat_file, const int type) {
+
+ if (macro_f_file_type_get(stat_file.st_mode) == type) return F_true;
+
+ return F_false;
+ }
+#endif // _di_f_file_is_stat_
+
#ifndef _di_f_file_link_
f_status_t f_file_link(const f_string_static_t target, const f_string_static_t point) {
#endif // _di_f_file_is_at_
/**
+ * Identify whether or not a file exists at the given path and if that file is a specific type using the statistics file data.
+ *
+ * This does not require access on the file itself.
+ * This only requires a populated statistics file structure.
+ *
+ * @param stat_file
+ * The statistics read.
+ * @param type
+ * The type of the file.
+ *
+ * @return
+ * F_true if path was found and path is type.
+ * F_false if path was found and path is not type.
+ */
+#ifndef _di_f_file_is_stat_
+ extern f_status_t f_file_is_stat(const struct stat stat_file, const int type);
+#endif // _di_f_file_is_stat_
+
+/**
* Create a symbolic link to a file.
*
* This will not replace existing files/links.
build_libraries -lc -lcmocka
build_libraries-individual -lf_memory -lf_string -lf_file
-build_sources_program test-file-access.c test-file-access_at.c test-file-clone.c test-file-close.c test-file-close_flush.c test-file-copy.c test-file-create.c test-file-create_at.c test-file-create_device.c test-file-create_device_at.c test-file-create_fifo.c test-file-create_fifo_at.c test-file-create_node.c test-file-create_node_at.c test-file-descriptor.c test-file-exists.c test-file-exists_at.c test-file-flush.c test-file-group_read.c test-file-is.c test-file-is_at.c test-file-link.c test-file-link_at.c test-file-link_hard.c test-file-link_hard_at.c test-file-link_read.c test-file-link_read_at.c test-file-mode_determine.c test-file-mode_from_string.c test-file-mode_read.c test-file-mode_read_at.c test-file-mode_set.c test-file-mode_set_at.c test-file-mode_to_mode.c test-file-name_base.c test-file-name_directory.c test-file-open.c test-file-open_at.c test-file-owner_read.c test-file-read.c test-file-read_block.c test-file-read_until.c test-file-remove.c test-file-remove_at.c test-file-rename.c test-file-rename_at.c test-file-role_change.c test-file-role_change_at.c test-file-seek.c test-file-size.c test-file-size_at.c test-file-size_by_id.c test-file-stat.c test-file-stat_at.c test-file-stat_by_id.c test-file-stream_close.c test-file-stream_open_descriptor.c test-file-stream_open.c test-file-stream_read.c test-file-stream_read_block.c test-file-stream_read_until.c test-file-stream_reopen.c test-file-stream_write.c test-file-stream_write_block.c test-file-stream_write_until.c test-file-stream_write_range.c test-file-touch.c test-file-touch_at.c test-file-type.c test-file-type_at.c test-file-umask_get.c test-file-umask_set.c test-file-write.c test-file-write_block.c test-file-write_until.c test-file-write_range.c
+build_sources_program test-file-access.c test-file-access_at.c test-file-clone.c test-file-close.c test-file-close_flush.c test-file-copy.c test-file-create.c test-file-create_at.c test-file-create_device.c test-file-create_device_at.c test-file-create_fifo.c test-file-create_fifo_at.c test-file-create_node.c test-file-create_node_at.c test-file-descriptor.c test-file-exists.c test-file-exists_at.c test-file-flush.c test-file-group_read.c test-file-is.c test-file-is_at.c test-file-is_stat.c test-file-link.c test-file-link_at.c test-file-link_hard.c test-file-link_hard_at.c test-file-link_read.c test-file-link_read_at.c test-file-mode_determine.c test-file-mode_from_string.c test-file-mode_read.c test-file-mode_read_at.c test-file-mode_set.c test-file-mode_set_at.c test-file-mode_to_mode.c test-file-name_base.c test-file-name_directory.c test-file-open.c test-file-open_at.c test-file-owner_read.c test-file-read.c test-file-read_block.c test-file-read_until.c test-file-remove.c test-file-remove_at.c test-file-rename.c test-file-rename_at.c test-file-role_change.c test-file-role_change_at.c test-file-seek.c test-file-size.c test-file-size_at.c test-file-size_by_id.c test-file-stat.c test-file-stat_at.c test-file-stat_by_id.c test-file-stream_close.c test-file-stream_open_descriptor.c test-file-stream_open.c test-file-stream_read.c test-file-stream_read_block.c test-file-stream_read_until.c test-file-stream_reopen.c test-file-stream_write.c test-file-stream_write_block.c test-file-stream_write_until.c test-file-stream_write_range.c test-file-touch.c test-file-touch_at.c test-file-type.c test-file-type_at.c test-file-umask_get.c test-file-umask_set.c test-file-write.c test-file-write_block.c test-file-write_until.c test-file-write_range.c
build_sources_program test-file.c
build_script no
--- /dev/null
+#include "test-file.h"
+#include "test-file-is.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_file_is_stat__returns_false(void **state) {
+
+ f_status_t types[] = {
+ F_file_type_block_d,
+ F_file_type_character_d,
+ F_file_type_directory_d,
+ F_file_type_fifo_d,
+ F_file_type_link_d,
+ F_file_type_mask_d,
+ F_file_type_regular_d,
+ F_file_type_socket_d,
+ };
+
+ for (int j = 0; j < 8; ++j) {
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof(struct stat));
+
+ statistics.st_mode = 1 | types[j];
+
+ for (int i = 0; i < 8; ++i) {
+
+ // Skip what would return true.
+ if (j == i) continue;
+
+ const f_status_t status = f_file_is_stat(statistics, types[i]);
+
+ assert_int_equal(status, F_false);
+ } // for
+ } // for
+}
+
+void test__f_file_is_stat__returns_true(void **state) {
+
+ f_status_t types[] = {
+ F_file_type_block_d,
+ F_file_type_character_d,
+ F_file_type_directory_d,
+ F_file_type_fifo_d,
+ F_file_type_link_d,
+ F_file_type_mask_d,
+ F_file_type_regular_d,
+ F_file_type_socket_d,
+ };
+
+ for (int j = 0; j < 8; ++j) {
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof(struct stat));
+
+ statistics.st_mode = 1 | types[j];
+
+ for (int i = 0; i < 8; ++i) {
+
+ // Skip what would return false.
+ if (j != i) continue;
+
+ const f_status_t status = f_file_is_stat(statistics, types[i]);
+
+ assert_int_equal(status, F_true);
+ } // for
+ } // for
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: File
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the file project.
+ */
+#ifndef _TEST__F_file_is_stat_h
+#define _TEST__F_file_is_stat_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_file_is_stat()
+ */
+extern void test__f_file_is_stat__fails(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_file_is_stat()
+ */
+extern void test__f_file_is_stat__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_file_is_stat()
+ */
+extern void test__f_file_is_stat__returns_true(void **state);
+
+#endif // _TEST__F_file_is_stat_h
cmocka_unit_test(test__f_file_is_at__returns_false),
cmocka_unit_test(test__f_file_is_at__returns_true),
+ cmocka_unit_test(test__f_file_is_stat__fails),
+ cmocka_unit_test(test__f_file_is_stat__returns_false),
+ cmocka_unit_test(test__f_file_is_stat__returns_true),
+
cmocka_unit_test(test__f_file_link__fails),
cmocka_unit_test(test__f_file_link__returns_data_not),
cmocka_unit_test(test__f_file_link__works),
cmocka_unit_test(test__f_file_group_read__parameter_checking),
// f_file_is() doesn't use parameter checking.
// f_file_is_at() doesn't use parameter checking.
+ // f_file_is_stat() doesn't use parameter checking.
// f_file_link() doesn't use parameter checking.
// f_file_link_at() doesn't use parameter checking.
// f_file_link_hard() doesn't use parameter checking.
#include "test-file-group_read.h"
#include "test-file-is.h"
#include "test-file-is_at.h"
+#include "test-file-is_stat.h"
#include "test-file-link.h"
#include "test-file-link_at.h"
#include "test-file-link_hard.h"