op_file.h revision cc2ee177dbb3befca43e36cfc56778b006c3d050
1/**
2 * @file op_file.h
3 * Useful file management helpers
4 *
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author John Levon
9 * @author Philippe Elie
10 */
11
12#ifndef OP_FILE_H
13#define OP_FILE_H
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include <sys/types.h>
20
21/**
22 * op_file_readable - is a file readable
23 * @param file file name
24 *
25 * Return true if the given file is readable and regular.
26 *
27 * Beware of race conditions !
28 */
29int op_file_readable(char const * file);
30
31/**
32 * op_get_mtime - get mtime of file
33 * @param file  file name
34 *
35 * Returns the mtime of the given file or 0 on failure
36 */
37time_t op_get_mtime(char const * file);
38
39/**
40 * create_dir - create a directory
41 * @param dir  the directory name to create
42 *
43 * Returns 0 on success.
44 */
45int create_dir(char const * dir);
46
47
48/**
49 * create_path - create a path
50 * @param path  the path to create
51 *
52 * create directory for each dir components in path
53 * the last path component is not considered as a directory
54 * but as a filename
55 *
56 * Returns 0 on success.
57 */
58int create_path(char const * path);
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif /* OP_FILE_H */
65