![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Cross-platform directory scanning (Linux/Solaris/Windows), optionnal recursion. More...
#include "nilorea/n_files.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdint.h>#include <dirent.h>#include <sys/stat.h>#include <errno.h>
Include dependency graph for n_files.c:Go to the source code of this file.
Functions | |
| int | n_comp_file_info (const void *a, const void *b) |
| Comparison function for sorting N_FILE_INFO by time (oldest first). | |
| void | n_free_file_info (void *ptr) |
| Cross-platform directory scanning (Linux / Solaris / Windows via MinGW) WITHOUT chdir(). | |
| char * | n_path_join (const char *dir, const char *name) |
| Build "dir + '/' + name" (or without extra slash if dir already ends with '/' or '\'). | |
| int | n_scan_dir (const char *dir, LIST *result, const int recurse) |
| Scan a directory and append only regular files into a sorted list (oldest first). | |
| void | n_set_time_from_stat (N_FILE_INFO *file, const struct stat *st) |
| Fill filetime and filetime_nsec from a struct stat (mtime). | |
Cross-platform directory scanning (Linux/Solaris/Windows), optionnal recursion.
Definition in file n_files.c.
| int n_comp_file_info | ( | const void * | a, |
| const void * | b | ||
| ) |
Comparison function for sorting N_FILE_INFO by time (oldest first).
Orders by: 1) filetime (seconds) ascending 2) filetime_nsec (nanoseconds) ascending
Return values:
| a | Pointer to first N_FILE_INFO |
| b | Pointer to second N_FILE_INFO |
Definition at line 121 of file n_files.c.
References N_FILE_INFO::filetime, and N_FILE_INFO::filetime_nsec.
Referenced by n_scan_dir().
Here is the caller graph for this function:| char * n_path_join | ( | const char * | dir, |
| const char * | name | ||
| ) |
Build "dir + '/' + name" (or without extra slash if dir already ends with '/' or '\').
Uses '/' as a separator for portability. Windows (MinGW) accepts forward slashes.
| dir | Base directory path (non-NULL) |
| name | Entry name (non-NULL) |
Definition at line 78 of file n_files.c.
Referenced by n_scan_dir().
Here is the caller graph for this function:| void n_set_time_from_stat | ( | N_FILE_INFO * | file, |
| const struct stat * | st | ||
| ) |
Fill filetime and filetime_nsec from a struct stat (mtime).
On Linux and Solaris, uses st_mtim (seconds + nanoseconds). On other POSIX environments, falls back to st_mtime (seconds only).
| file | N_FILE_INFO to fill (non-NULL) |
| st | struct stat source (non-NULL) |
Definition at line 146 of file n_files.c.
References N_FILE_INFO::filetime, and N_FILE_INFO::filetime_nsec.
Referenced by n_scan_dir().
Here is the caller graph for this function: