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