Debian Codegraph @

Xpjproject/pjlib/include/pj/file_access.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
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
28 PJ_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 */
42 typedef 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 */
58 PJ_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 */
67 PJ_DECL(pj_off_t) pj_file_size(const char *filename);
68
69 /**
70 * Returns the size of the file.
71 *
72 * @param fh The file handle (or FILE* for ansi file backend).
73 *
74 * @return The file size in bytes or -1 on error.
75 */
76 PJ_DECL(pj_off_t) pj_file_size_by_handle(pj_oshandle_t fh);
77
78 /**
79 * Delete a file.
80 *
81 * @param filename The filename.
82 *
83 * @return PJ_SUCCESS on success or the appropriate error code.
84 */
85 PJ_DECL(pj_status_t) pj_file_delete(const char *filename);
86
87 /**
88 * Move a \c oldname to \c newname. If \c newname already exists,
89 * it will be overwritten.
90 *
91 * @param oldname The file to rename.
92 * @param newname New filename to assign.
93 *
94 * @return PJ_SUCCESS on success or the appropriate error code.
95 */
96 PJ_DECL(pj_status_t) pj_file_move( const char *oldname,
97 const char *newname);
98
99
100 /**
101 * Return information about the specified file. The time information in
102 * the \c stat structure will be in local time.
103 *
104 * @param filename The filename.
105 * @param stat Pointer to variable to receive file information.
106 *
107 * @return PJ_SUCCESS on success or the appropriate error code.
108 */
109 PJ_DECL(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat);
110
111
112 /** @} */
113
114 PJ_END_DECL
115
116
117 #endif /* __PJ_FILE_ACCESS_H__ */