blob: 5eed23da787dfd0138eee837fc051a047ce4eda3 [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id */
2/*
3 * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_FILE_ACCESS_H__
20#define __PJ_FILE_ACCESS_H__
21
22/**
23 * @file file_access.h
24 * @brief File manipulation and access.
25 */
26#include <pj/types.h>
27
28PJ_BEGIN_DECL
29
30/**
31 * @defgroup PJ_FILE_ACCESS File Access
32 * @ingroup PJ_IO
33 * @{
34 *
35 */
36
37/**
38 * This structure describes file information, to be obtained by
39 * calling #pj_file_getstat(). The time information in this structure
40 * is in local time.
41 */
42typedef struct pj_file_stat
43{
44 pj_off_t size; /**< Total file size. */
45 pj_time_val atime; /**< Time of last access. */
46 pj_time_val mtime; /**< Time of last modification. */
47 pj_time_val ctime; /**< Time of last creation. */
48} pj_file_stat;
49
50
51/**
52 * Returns non-zero if the specified file exists.
53 *
54 * @param filename The file name.
55 *
56 * @return Non-zero if the file exists.
57 */
58PJ_DECL(pj_bool_t) pj_file_exists(const char *filename);
59
60/**
61 * Returns the size of the file.
62 *
63 * @param filename The file name.
64 *
65 * @return The file size in bytes or -1 on error.
66 */
67PJ_DECL(pj_off_t) pj_file_size(const char *filename);
68
69/**
70 * Delete a file.
71 *
72 * @param filename The filename.
73 *
74 * @return PJ_SUCCESS on success or the appropriate error code.
75 */
76PJ_DECL(pj_status_t) pj_file_delete(const char *filename);
77
78/**
79 * Move a \c oldname to \c newname. If \c newname already exists,
80 * it will be overwritten.
81 *
82 * @param oldname The file to rename.
83 * @param newname New filename to assign.
84 *
85 * @return PJ_SUCCESS on success or the appropriate error code.
86 */
87PJ_DECL(pj_status_t) pj_file_move( const char *oldname,
88 const char *newname);
89
90
91/**
92 * Return information about the specified file. The time information in
93 * the \c stat structure will be in local time.
94 *
95 * @param filename The filename.
96 * @param stat Pointer to variable to receive file information.
97 *
98 * @return PJ_SUCCESS on success or the appropriate error code.
99 */
100PJ_DECL(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat);
101
102
103/** @} */
104
105PJ_END_DECL
106
107
108#endif /* __PJ_FILE_ACCESS_H__ */