#include <dk.h>
#include <dktypes.h>
#include <dksfc.h>
Go to the source code of this file.
Defines | |
#define | DK_SF_SEC_WG 1 |
Security check: File group writable? | |
#define | DK_SF_SEC_WO 2 |
Security check: File writable for others (all)? | |
#define | DK_SF_SEC_OWNER 4 |
Security check: For symlinks, do symlink owner and file owner match? | |
#define | DK_SF_SEC_DIR 8 |
Security check: Is the path name a directory? | |
Functions | |
dk_stat_t * | dkstat_open (char *n) |
Create a dk_stat_t structure and collect information about a file. | |
dk_stat_t * | dkstat_new (void) |
Create a new empty dk_stat_t structure. | |
int | dkstat_get (dk_stat_t *p, char *n) |
Load information about a file into a dk_stat_t structure. | |
void | dkstat_delete (dk_stat_t *p) |
Release memory for a structure obtained by dkstat_new(). | |
void | dkstat_close (dk_stat_t *p) |
Close a dk_stat_t structure obtained by dkstat_open() and release memory. | |
int | dkstat_filetype (dk_stat_t *p) |
Get file type. | |
int | dkstat_permissions (dk_stat_t *p) |
Get permissions. | |
unsigned long | dkstat_inode (dk_stat_t *p) |
Get inode number. | |
unsigned long | dkstat_device (dk_stat_t *p) |
Get device number. | |
unsigned long | dkstat_rdevice (dk_stat_t *p) |
Get relative device number. | |
unsigned long | dkstat_nlinks (dk_stat_t *p) |
Get number of links. | |
dk_long_long_unsigned_t | dkstat_size (dk_stat_t *p) |
Get file size. | |
dk_long_long_unsigned_t | dkstat_size_ok (dk_stat_t *p, int *ok) |
Get file size, indicate numeric overflow error if necessary. | |
long | dkstat_uid (dk_stat_t *p) |
Get owner UID. | |
long | dkstat_gid (dk_stat_t *p) |
Get owner GID. | |
char * | dkstat_ctime (dk_stat_t *p) |
Get creation time. | |
char * | dkstat_atime (dk_stat_t *p) |
Get last access time. | |
char * | dkstat_mtime (dk_stat_t *p) |
Get last modification time. | |
int | dkstat_far_link (dk_stat_t *p) |
Check whether or not the file is a far symbolic link (link to a destination outside the current file system). | |
dk_dir_t * | dkdir_open (char *n) |
Open a directory. | |
void | dkdir_close (dk_dir_t *d) |
Close a directory. | |
dk_dir_t * | dkdir_new (void) |
Create a new empty dk_dir_t structure. | |
void | dkdir_delete (dk_dir_t *d) |
Release memory for dk_dir_t structure. | |
int | dkdir_start_search (dk_dir_t *d, char *n) |
Start traversing directory. | |
void | dkdir_end_search (dk_dir_t *d) |
End traversing a directory. | |
int | dkdir_next (dk_dir_t *d) |
Check for next directory entry. | |
char * | dkdir_get_fullname (dk_dir_t *d) |
Retrieve full file name. | |
char * | dkdir_get_shortname (dk_dir_t *d) |
Retrieve short file name. | |
long | dkdir_uid (dk_dir_t *d) |
Get owner UID. | |
long | dkdir_gid (dk_dir_t *d) |
Get owner GID. | |
char * | dkdir_ctime (dk_dir_t *d) |
Get creation time. | |
char * | dkdir_atime (dk_dir_t *d) |
Get last access time. | |
char * | dkdir_mtime (dk_dir_t *d) |
Get modification time. | |
int | dkdir_filetype (dk_dir_t *d) |
Get file type. | |
int | dkdir_permissions (dk_dir_t *d) |
Get permissions. | |
unsigned long | dkdir_inode (dk_dir_t *d) |
Get inode number. | |
unsigned long | dkdir_device (dk_dir_t *d) |
Get device number. | |
unsigned long | dkdir_rdevice (dk_dir_t *d) |
Get relative device number. | |
unsigned long | dkdir_nlinks (dk_dir_t *d) |
Get number of links. | |
dk_long_long_unsigned_t | dkdir_size (dk_dir_t *d) |
Get entry size. | |
dk_long_long_unsigned_t | dkdir_size_ok (dk_dir_t *d, int *ok) |
Get entry size and check for overflow. | |
dk_stat_t * | dkdir_stat (dk_dir_t *d) |
Retrieve all information about the current entry. | |
int | dksf_must_expand_filename (char *n) |
Check whether file name needs expansion. | |
dk_fne_t * | dkfne_open (char *n, int f, int d) |
Open file name expander. | |
void | dkfne_close (dk_fne_t *f) |
Close file name expander. | |
int | dkfne_next (dk_fne_t *f) |
Check for next file matching the pattern. | |
char * | dkfne_get_one (dk_fne_t *f) |
Check whether or not the pattern matches exactly one file name. | |
char * | dkfne_get_fullname (dk_fne_t *f) |
Get full file name. | |
char * | dkfne_get_shortname (dk_fne_t *f) |
Get short file name. | |
int | dkfne_get_error_code (dk_fne_t *f, int r) |
Retrieve error code. | |
int | dksf_mkdir (char *p, int m) |
Make directory. | |
int | dksf_chmod (char *p, int m) |
Change access permissions. | |
int | dksf_fchmod (int fd, int m) |
Change access permissions of an opened file. | |
int | dksf_have_getuid (void) |
Check whether the system supports user IDs. | |
long | dksf_getuid (void) |
Get current user ID. | |
int | dksf_have_geteuid (void) |
Check whether the system supports dksf_geteuid(). | |
long | dksf_geteuid (void) |
Get effective user ID. | |
int | dksf_have_getgid (void) |
Check whether the system supports group IDs and dksf_getgid(). | |
long | dksf_getgid (void) |
Get group ID. | |
int | dksf_have_getegid (void) |
Check whether the system supports dksf_getegid(). | |
long | dksf_getegid (void) |
Get effective group ID. | |
int | dksf_have_getpid (void) |
Check whether the system supports process IDs and dksf_getpid(). | |
long | dksf_getpid (void) |
Get process ID. | |
int | dksf_have_getppid (void) |
Check whether the system supports dksf_getppid(). | |
long | dksf_getppid (void) |
Get parent process ID. | |
int | dksf_have_getpgrp (void) |
Check whether the system supports process group IDs and dksf_getpgrp(). | |
long | dksf_getpgrp (void) |
Get process group ID. | |
int | dksf_have_getpgid (void) |
Check whether the system supports dksf_getpgid(). | |
long | dksf_getpgid (long p) |
Get process group ID of another process. | |
int | dksf_get_uname (char *b, size_t s) |
Get current user name. | |
int | dksf_get_euname (char *b, size_t s) |
Get effective user name. | |
int | dksf_get_home (char *b, size_t s) |
Get current users home directory. | |
int | dksf_get_ehome (char *b, size_t s) |
Get effective users home directory. | |
int | dksf_get_hostname (char *b, size_t s) |
Get host name. | |
int | dksf_get_domainname (char *b, size_t s) |
Get DNS domain name of host. | |
int | dksf_get_tempdir (char *b, size_t s) |
Get name of directory for temporary files. | |
long | dksf_get_maxpathlen (void) |
Get maximum length of a path in characters. | |
long | dksf_get_maxfiles (void) |
Get maximum number of open files. | |
int | dksf_getcwd (char *b, size_t s) |
Get current working directory. | |
int | dksf_get_executable (char *b, size_t s, char *d, char *p, int w) |
Get full file name (including path) of executable file. | |
int | dksf_path_combine (char *b, size_t s, char *c, char *p) |
Combine paths. | |
int | dksf_is_abs_path (char *p) |
Check absolute path name. | |
char * | dksf_get_file_type_dot (char *p) |
Find file name suffix. | |
char * | dksf_get_last_filename (char *p) |
Find last path name component. | |
void | dksf_time_convert (char *b, time_t t) |
Convert time stamp to text representation. | |
void | dksf_correct_fnsep (char *p) |
Correct file name separators. | |
int | dksf_remove_directory (char *p) |
Remove directory. | |
int | dksf_remove_file (char *p) |
Remove a file. | |
int | dksf_allowed_to_write (char *p, int i, int *r) |
Security checks before overwriting a file. | |
FILE * | dksf_msfo (char *p, char *m, int i, int *r) |
Open a file, apply security checks. | |
FILE * | dksf_fopen (char *p, char *m) |
Open a file, apply security checks. | |
int | dksf_fdesk_binary (int f, int b) |
Switch file descriptor to binary mode. | |
int | dksf_get_filetype (char *p) |
Get file type. | |
int | dksf_is_directory (char *p) |
Check whether a path name is a directory. | |
int | dksf_no_core (void) |
Deny the creation of core files. | |
int | dksf_echo_test_tty (void) |
Check whether or not standard input is connected to a terminal. | |
int | dksf_echo_save (dk_echo_t *e) |
Save current keyboard echo setting. | |
int | dksf_echo_restore (dk_echo_t *e) |
Restore keyboard echo setting. | |
int | dksf_echo_is_tty (dk_echo_t *e) |
Check whether the keyboard echo data belongs to a terminal. | |
int | dksf_echo_off (dk_echo_t *e) |
Turn keyboard echo off. | |
unsigned long | dksf_filesize_bytes (void) |
Get size of file size data type in bytes. | |
unsigned long | dksf_long_long_bytes (void) |
Get size of long long type in bytes. | |
int | dksf_must_rebuild (char *d, char *s) |
Check whether a destination file must be rebuild. |
Unless otherwise stated, int functions in this module return a positive number to indicate success or a true condition, 0 to indicate an error or an unfullfilled condition. Pointer functions return valid pointers on success, NULL on error.
The dkstat_xxx() function group can be used to obtain information about a file or directory. In a first step information about the file is collected and stored in a dk_stat_t data structure. The further dkstat_xxx() functions can be used to retrieve details from the structure.
dk_stat_t *p; p = dk_stat_open("x.txt"); if(p) { ... retrieve information from p ... dkstat_close(p); }
The dkdir_xxx() function group can be used to traverse directories.
dk_dir_t *p; p = dkdir_open("."); if(p) { while(dkdir_next(p)) { ... yet another entry found ... ... retrieve information from p ... } dkdir_close(p); }
The dkfne_xxx() function group can be used to expand file name patterns (some Windows command interpreters do not expand wildcards and leave this up to applications).
To find all regular file names (1 in dkfne_open()) but no directories (0 in dkfne_open()) matching a file name pattern n use:
char *n = ... file name ... ; char *fn = NULL; dk_fne_t *fne; if(dksf_must_expand_filename(n)) { fne = dkfne_open(n, 1, 0); if(fne) { while(dkfne_next(fne)) { fn = dkfne_get_fullname(fne); ... fn is a file name ... } dkfne_close(fne); ... fn can not longer be used, it pointed into fne ... } else { ... error, failed to create fne ... } }
If file name pattern n should choose exactly one file name use:
char *n = ... file name ... ; char *fn = NULL; dk_fne_t *fne; if(dksf_must_expand_filename(n)) { fne = dkfne_open(n, 1, 0); if(fne) { fn = dkfne_get_one(fne); if(fn) { ... fn is a file name ... } else { ... error, not exactly one name matches ... } dkfne_close(fne); ... fn can not longer be used, it pointed into fne ... } else { ... error, failed to create fne ... } }
The dksf_echo_xxx() function group deals with keyboard echo on terminals.
dk_echo_t echodata; if(dksf_echo_test_tty()) { ... standard input is connected to terminal ... if(dksf_echo_save(&echodata)) { if(dksf_echo_off(&echodata)) { ... ask user for password ... ... read password from standard input ... } else { ... error, failed to turn echo off ... } dksf_echo_restore(&echodata); } else { ... error, failed to save current echo state ... } } else { ... error, standard input is not a terminal ... }
char* dkdir_atime | ( | dk_dir_t * | d | ) |
Get last access time.
d | Directory structure. |
void dkdir_close | ( | dk_dir_t * | d | ) |
Close a directory.
d | Directory to close. |
char* dkdir_ctime | ( | dk_dir_t * | d | ) |
Get creation time.
d | Directory structure. |
void dkdir_delete | ( | dk_dir_t * | d | ) |
unsigned long dkdir_device | ( | dk_dir_t * | d | ) |
Get device number.
d | Directory structure. |
void dkdir_end_search | ( | dk_dir_t * | d | ) |
End traversing a directory.
The function finishes a directory traversal formerly started by dkdir_start_search().
d | Directory structure. |
int dkdir_filetype | ( | dk_dir_t * | d | ) |
Get file type.
d | Directory structure. |
char* dkdir_get_fullname | ( | dk_dir_t * | d | ) |
Retrieve full file name.
d | Directory structure. |
char* dkdir_get_shortname | ( | dk_dir_t * | d | ) |
Retrieve short file name.
d | Directory structure. |
long dkdir_gid | ( | dk_dir_t * | d | ) |
Get owner GID.
d | Directory structure. |
unsigned long dkdir_inode | ( | dk_dir_t * | d | ) |
Get inode number.
d | Directory structure. |
char* dkdir_mtime | ( | dk_dir_t * | d | ) |
Get modification time.
d | Directory structure. |
dk_dir_t* dkdir_new | ( | void | ) |
Create a new empty dk_dir_t structure.
A pointer to a the new structure is returned. The memory must be release using dkdir_delete() after usage.
int dkdir_next | ( | dk_dir_t * | d | ) |
Check for next directory entry.
This function checks whether or not there is yet another entry in the directory which was not yet found in the current directory traversal. If this function returns successfully you can use the functions below -- dkdir_get_fullname(), dkdir_get_shortname(), dkdir_uid(), dkdir_gid(), dkdir_ctime(), dkdir_atime(), dkdir_mtime(), dkdir_filetype(), dkdir_permissions(), dkdir_inode(), dkdir_device(), dkdir_rdevice(), dkdir_nlinks(), dkdir_size() and dkdir_size_ok() -- to obtain information about the entry. The char * functions return pointers to elements of d, these pointers can not longer be used after dkdir_delete() or dkdir_close(). The d members will change in the next call to dkdir_next().
d | Directory structure. |
unsigned long dkdir_nlinks | ( | dk_dir_t * | d | ) |
Get number of links.
d | Directory structure. |
dk_dir_t* dkdir_open | ( | char * | n | ) |
Open a directory.
n | Name of directory. |
int dkdir_permissions | ( | dk_dir_t * | d | ) |
Get permissions.
d | Directory structure. |
unsigned long dkdir_rdevice | ( | dk_dir_t * | d | ) |
Get relative device number.
d | Directory structure. |
dk_long_long_unsigned_t dkdir_size | ( | dk_dir_t * | d | ) |
Get entry size.
d | Directory structure. |
dk_long_long_unsigned_t dkdir_size_ok | ( | dk_dir_t * | d, | |
int * | ok | |||
) |
Get entry size and check for overflow.
d | Directory structure | |
ok | Pointer to variable receiving an error code if an error occurs. |
int dkdir_start_search | ( | dk_dir_t * | d, | |
char * | n | |||
) |
Start traversing directory.
The function starts a new directory traversal for a dk_dir_t structure. This is only necessary for a dk_dir_t obtained from dkdir_new().
d | Directory structure. | |
n | Name of directory. |
Retrieve all information about the current entry.
This function returns a pointer to a member of d. Do not attempt to release this memory using dkstat_close(). The pointer can not be used after the dk_dir_t structure was released using dkdir_close() or dkdir_delete().
d | Directory structure. |
long dkdir_uid | ( | dk_dir_t * | d | ) |
Get owner UID.
d | Directory structure. |
void dkfne_close | ( | dk_fne_t * | f | ) |
Close file name expander.
f | File name expander to close and release. |
int dkfne_get_error_code | ( | dk_fne_t * | f, | |
int | r | |||
) |
Retrieve error code.
This function returns the error code for the last error occured. Optionally the error code variable can be reset.
f | File name expander. | |
r | Flag to indicate whether (non-zero value) or not (0) the error code member variable must be reset. |
char* dkfne_get_fullname | ( | dk_fne_t * | f | ) |
Get full file name.
f | File name expander. |
char* dkfne_get_one | ( | dk_fne_t * | f | ) |
Check whether or not the pattern matches exactly one file name.
If the function returns successfully you can use dkfne_get_fullname() or dkfne_get_shortname() to retrieve the name of the entry found. These functions return pointers to components of f, so the pointer can not be used after releasing the structure using dkfne_close(). The components are modified by the next call to dkfne_next() or dkfne_get_one().
f | File name expander. |
char* dkfne_get_shortname | ( | dk_fne_t * | f | ) |
Get short file name.
f | File name expander. |
int dkfne_next | ( | dk_fne_t * | f | ) |
Check for next file matching the pattern.
If the function returns successfully you can use dkfne_get_fullname() or dkfne_get_shortname() to retrieve the name of the entry found. These functions return pointers to components of f, so the pointer can not be used after releasing the structure using dkfne_close(). The components are modified by the next call to dkfne_next() or dkfne_get_one().
f | File name expander. |
dk_fne_t* dkfne_open | ( | char * | n, | |
int | f, | |||
int | d | |||
) |
Open file name expander.
The file name expander structure (dk_fne_t) is created in dynamically allocated memory, you must release it after usage calling the dkfne_close() function.
n | File name pattern containing wildcards ('*', '?'). | |
f | Flag whether (non-zero value) or not (0) to search for files. | |
d | Flag whether (non-zero value) nor not (0) to search for directories. |
int dksf_allowed_to_write | ( | char * | p, | |
int | i, | |||
int * | r | |||
) |
Security checks before overwriting a file.
This function checks whether a file can be overwritten. Even if file permissions allow writing we should do additional checks:
p | Path name of file to open. | |
i | Security checks to ignore (or-combination of DK_SF_SEC_xxx constants. | |
r | Pointer to a variable to receive the reason if opening The file is denied due to failed security checks. |
int dksf_chmod | ( | char * | p, | |
int | m | |||
) |
Change access permissions.
p | Path name of the file or directory. | |
m | New access permissions (or-combination of DK_PERM_...-constants). |
void dksf_correct_fnsep | ( | char * | p | ) |
Correct file name separators.
Some systems use slashes other systems use backslashes to separate parts in a path name. This function converts slashes into backslashes or backslashes into slashes.
p | Path name. |
int dksf_echo_is_tty | ( | dk_echo_t * | e | ) |
Check whether the keyboard echo data belongs to a terminal.
e | Structure for keyboard echo data. |
int dksf_echo_off | ( | dk_echo_t * | e | ) |
Turn keyboard echo off.
e | Structure for keyboard echo data. |
int dksf_echo_restore | ( | dk_echo_t * | e | ) |
Restore keyboard echo setting.
e | Structure to restore data from. |
int dksf_echo_save | ( | dk_echo_t * | e | ) |
Save current keyboard echo setting.
e | Structure to save data to. |
int dksf_echo_test_tty | ( | void | ) |
Check whether or not standard input is connected to a terminal.
int dksf_fchmod | ( | int | fd, | |
int | m | |||
) |
Change access permissions of an opened file.
fd | File descriptor. | |
m | New access permissions (or-combination of DK_PER_...-constants). |
int dksf_fdesk_binary | ( | int | f, | |
int | b | |||
) |
Switch file descriptor to binary mode.
On Windows systems this function switches a file descriptor f to binary or text mode depending on the b flag. On other systems this function has no impact.
f | File descriptor. | |
b | Flag to indicate whether to bring the file descriptor into binary or text mode. |
unsigned long dksf_filesize_bytes | ( | void | ) |
Get size of file size data type in bytes.
FILE* dksf_fopen | ( | char * | p, | |
char * | m | |||
) |
Open a file, apply security checks.
This function is intended as a replacement for fopen(). Before calling fopen() all the DK_SF_SEC_xxx security checks are applied.
p | Path name of file to open. | |
m | File open mode, i.e. "r", "w"... |
int dksf_get_domainname | ( | char * | b, | |
size_t | s | |||
) |
Get DNS domain name of host.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_get_ehome | ( | char * | b, | |
size_t | s | |||
) |
Get effective users home directory.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_get_euname | ( | char * | b, | |
size_t | s | |||
) |
Get effective user name.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_get_executable | ( | char * | b, | |
size_t | s, | |||
char * | d, | |||
char * | p, | |||
int | w | |||
) |
Get full file name (including path) of executable file.
b | Pointer to buffer receiving the result. | |
s | Size of b. | |
d | Current working directory. | |
p | Program name from argv[0]. | |
w | Flag to allow Windows functions GetModuleFileNameA() and GetModuleHandle() on Windows systems. Recommended value: 1. |
char* dksf_get_file_type_dot | ( | char * | p | ) |
Find file name suffix.
The function searches for the suffix of the file name p.
p | Path name. |
int dksf_get_filetype | ( | char * | p | ) |
Get file type.
This function returns the file type (regular file, directory, socket...) as DK_SF_FT_xxx constant.
p | Path name. |
int dksf_get_home | ( | char * | b, | |
size_t | s | |||
) |
Get current users home directory.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_get_hostname | ( | char * | b, | |
size_t | s | |||
) |
Get host name.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
char* dksf_get_last_filename | ( | char * | p | ) |
Find last path name component.
p | Path name. |
long dksf_get_maxfiles | ( | void | ) |
Get maximum number of open files.
long dksf_get_maxpathlen | ( | void | ) |
Get maximum length of a path in characters.
int dksf_get_tempdir | ( | char * | b, | |
size_t | s | |||
) |
Get name of directory for temporary files.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_get_uname | ( | char * | b, | |
size_t | s | |||
) |
Get current user name.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
int dksf_getcwd | ( | char * | b, | |
size_t | s | |||
) |
Get current working directory.
b | Pointer to buffer receiving the result. | |
s | Size of b. |
long dksf_getegid | ( | void | ) |
Get effective group ID.
long dksf_geteuid | ( | void | ) |
Get effective user ID.
long dksf_getgid | ( | void | ) |
Get group ID.
long dksf_getpgid | ( | long | p | ) |
Get process group ID of another process.
p | The process ID of a process. |
long dksf_getpgrp | ( | void | ) |
Get process group ID.
long dksf_getpid | ( | void | ) |
Get process ID.
long dksf_getppid | ( | void | ) |
Get parent process ID.
long dksf_getuid | ( | void | ) |
Get current user ID.
int dksf_have_getegid | ( | void | ) |
Check whether the system supports dksf_getegid().
int dksf_have_geteuid | ( | void | ) |
Check whether the system supports dksf_geteuid().
int dksf_have_getgid | ( | void | ) |
Check whether the system supports group IDs and dksf_getgid().
int dksf_have_getpgid | ( | void | ) |
Check whether the system supports dksf_getpgid().
int dksf_have_getpgrp | ( | void | ) |
Check whether the system supports process group IDs and dksf_getpgrp().
int dksf_have_getpid | ( | void | ) |
Check whether the system supports process IDs and dksf_getpid().
int dksf_have_getppid | ( | void | ) |
Check whether the system supports dksf_getppid().
int dksf_have_getuid | ( | void | ) |
Check whether the system supports user IDs.
int dksf_is_abs_path | ( | char * | p | ) |
Check absolute path name.
The function checks, whether or not p is an absolute path name.
p | The path name to check |
int dksf_is_directory | ( | char * | p | ) |
Check whether a path name is a directory.
p | Path name. |
unsigned long dksf_long_long_bytes | ( | void | ) |
Get size of long long type in bytes.
int dksf_mkdir | ( | char * | p, | |
int | m | |||
) |
Make directory.
p | Path name of the new directory. | |
m | Access permissions to the new directory (or-combined DK_PERM_...-constants). |
FILE* dksf_msfo | ( | char * | p, | |
char * | m, | |||
int | i, | |||
int * | r | |||
) |
Open a file, apply security checks.
Before opening the file this function uses dksf_allowed_to_write() for additional security checks.
p | Path name of file to open | |
m | File open mode, i.e. "r", "w",... | |
i | Security checks to ignore (or-combination of DK_SF_SEC_xxx constants). | |
r | Pointer to a variable to receive the reason if opening the file is denied due to failed security checks. |
int dksf_must_expand_filename | ( | char * | n | ) |
Check whether file name needs expansion.
This function checks whether the file name must be expanded. A file name must be expanded on Windows systems if the name contains wildcards ('*' or '?').
n | File name to inspect. |
int dksf_must_rebuild | ( | char * | d, | |
char * | s | |||
) |
Check whether a destination file must be rebuild.
d | Name of destination file. | |
s | Name of source file. |
int dksf_no_core | ( | void | ) |
Deny the creation of core files.
This functtion sets the allowed size of core files to 0 if supported by the system.
int dksf_path_combine | ( | char * | b, | |
size_t | s, | |||
char * | c, | |||
char * | p | |||
) |
Combine paths.
b | Pointer to buffer receiving the result. | |
s | Size of b. | |
c | Base directory (i.e. current directory). | |
p | Path name to add. |
int dksf_remove_directory | ( | char * | p | ) |
Remove directory.
The directory is removed, including all contents.
p | Path name of directory to delete. |
int dksf_remove_file | ( | char * | p | ) |
Remove a file.
p | Path name of the file. |
void dksf_time_convert | ( | char * | b, | |
time_t | t | |||
) |
Convert time stamp to text representation.
b | Buffer to receive result, must be 21 at least. | |
t | Time stamp. |
char* dkstat_atime | ( | dk_stat_t * | p | ) |
Get last access time.
p | Pointer to dk_stat_t structure. |
void dkstat_close | ( | dk_stat_t * | p | ) |
Close a dk_stat_t structure obtained by dkstat_open() and release memory.
p | Pointer to dk_stat_t structure to release. |
char* dkstat_ctime | ( | dk_stat_t * | p | ) |
Get creation time.
p | Pointer to dk_stat_t structure. |
void dkstat_delete | ( | dk_stat_t * | p | ) |
Release memory for a structure obtained by dkstat_new().
p | Pointer to dk_stat_t structure to release. |
unsigned long dkstat_device | ( | dk_stat_t * | p | ) |
int dkstat_far_link | ( | dk_stat_t * | p | ) |
Check whether or not the file is a far symbolic link (link to a destination outside the current file system).
p | Pointer to dk_stat_t structure. |
int dkstat_filetype | ( | dk_stat_t * | p | ) |
Get file type.
The file type is returned as DK_FT_xxx constant. If the file name pointed to a symbolic link the result is an or-combination of the real file type and DK_FT_SYMLINK.
p | Pointer to dk_stat_t structure. |
int dkstat_get | ( | dk_stat_t * | p, | |
char * | n | |||
) |
long dkstat_gid | ( | dk_stat_t * | p | ) |
unsigned long dkstat_inode | ( | dk_stat_t * | p | ) |
char* dkstat_mtime | ( | dk_stat_t * | p | ) |
Get last modification time.
p | Pointer to dk_stat_t structure. |
dk_stat_t* dkstat_new | ( | void | ) |
Create a new empty dk_stat_t structure.
Memory for this structure is allocated dynamically, call dkstat_delete() to release the memory after usage. The structure only contains default values, use dkstat_get() to load information about a file into the structure.
unsigned long dkstat_nlinks | ( | dk_stat_t * | p | ) |
dk_stat_t* dkstat_open | ( | char * | n | ) |
Create a dk_stat_t structure and collect information about a file.
The function collects information about the file n and stores it into a new dk_stat_t structure. Memory for this structure is allocated dynamically, call dkstat_close() to release the memory after usage.
n | The file name. |
int dkstat_permissions | ( | dk_stat_t * | p | ) |
Get permissions.
The permissions are an or-combination of DK_PERM_xxx constants.
p | Pointer to dk_stat_t structure. |
unsigned long dkstat_rdevice | ( | dk_stat_t * | p | ) |
Get relative device number.
p | Pointer to dk_stat_t structure. |
dk_long_long_unsigned_t dkstat_size | ( | dk_stat_t * | p | ) |
dk_long_long_unsigned_t dkstat_size_ok | ( | dk_stat_t * | p, | |
int * | ok | |||
) |
Get file size, indicate numeric overflow error if necessary.
p | Pointer to dk_stat_t structure. | |
ok | Pointer to variable to receive the error code. The variable is left untouched if no error occures. If there was an error while retrieving the file size the variable is set to DK_ERR_MATH_OOR. |
long dkstat_uid | ( | dk_stat_t * | p | ) |