/usr/include/pj++/file.hpp is in libpjproject-dev 2.1.0.0.ast20130823-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /* $Id: file.hpp 2394 2008-12-23 17:27:53Z bennylp $ */
/*
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJPP_FILE_HPP__
#define __PJPP_FILE_HPP__
#include <pj/file_io.h>
#include <pj/file_access.h>
#include <pj++/types.hpp>
#include <pj++/pool.hpp>
//
// File API.
//
class Pj_File_API
{
public:
//
// Check file existance.
//
static bool file_exists(const char *filename)
{
return pj_file_exists(filename) != 0;
}
//
// Get file size.
//
static pj_off_t file_size(const char *filename)
{
return pj_file_size(filename);
}
//
// Delete file.
//
static pj_status_t file_delete(const char *filename)
{
return pj_file_delete(filename);
}
//
// Move/rename file.
//
static pj_status_t file_move(const char *oldname, const char *newname)
{
return pj_file_move(oldname, newname);
}
//
// Get stat.
//
static pj_status_t file_stat(const char *filename, pj_file_stat *buf)
{
return pj_file_getstat(filename, buf);
}
};
//
// File.
//
class Pj_File : public Pj_Object
{
public:
//
// Offset type to be used in setpos.
//
enum Offset_Type
{
PJ_SEEK_SET = PJ_SEEK_SET,
PJ_SEEK_CUR = PJ_SEEK_CUR,
PJ_SEEK_END = PJ_SEEK_END,
};
//
// Default constructor.
//
Pj_File()
: hnd_(0)
{
}
//
// Construct and open a file.
//
Pj_File(Pj_Pool *pool, const char *filename,
unsigned access = PJ_O_RDONLY)
: hnd_(NULL)
{
open(pool, filename, access);
}
//
// Destructor closes the file.
//
~Pj_File()
{
close();
}
//
// Open a file.
//
pj_status_t open(Pj_Pool *pool, const char *filename,
unsigned access = PJ_O_RDONLY )
{
close();
return pj_file_open(pool->pool_(), filename, access, &hnd_);
}
//
// Close a file.
//
void close()
{
if (hnd_ != 0) {
pj_file_close(hnd_);
hnd_ = 0;
}
}
//
// Write data.
//
pj_ssize_t write(const void *buff, pj_size_t size)
{
pj_ssize_t bytes = size;
if (pj_file_write(hnd_, buff, &bytes) != PJ_SUCCESS)
return -1;
return bytes;
}
//
// Read data.
//
pj_ssize_t read(void *buf, pj_size_t size)
{
pj_ssize_t bytes = size;
if (pj_file_read(hnd_, buf, &bytes) != PJ_SUCCESS)
return -1;
return bytes;
}
//
// Set file position.
//
pj_status_t setpos(pj_off_t offset, Offset_Type whence)
{
return pj_file_setpos(hnd_, offset,
(enum pj_file_seek_type)whence);
}
//
// Get file position.
//
pj_off_t getpos()
{
pj_off_t pos;
if (pj_file_getpos(hnd_, &pos) != PJ_SUCCESS)
return -1;
return pos;
}
private:
pj_oshandle_t hnd_;
};
#endif /* __PJPP_FILE_HPP__ */
|