/usr/include/ptclib/memfile.h is in libpt-dev 2.10.11~dfsg-2.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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | /*
* memfile.h
*
* WAV file I/O channel class.
*
* Portable Windows Library
*
* Copyright (c) 2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is
* Equivalence Pty Ltd
*
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 26949 $
* $Author: rjongbloed $
* $Date: 2012-02-07 20:27:07 -0600 (Tue, 07 Feb 2012) $
*/
#ifndef PTLIB_PMEMFILE_H
#define PTLIB_PMEMFILE_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
/**This class is used to allow a block of memory to substitute for a disk file.
*/
class PMemoryFile : public PFile
{
PCLASSINFO(PMemoryFile, PFile);
public:
/**@name Construction */
//@{
/**Create a new, empty, memory file.
*/
PMemoryFile();
/**Create a new memory file initialising to the specified content.
*/
PMemoryFile(
const PBYTEArray & data ///< New content filr memory file.
);
/**Destroy the memory file
*/
~PMemoryFile();
//@}
/**@name Overrides from class PObject */
//@{
/**Determine the relative rank of the two objects. This is essentially the
string comparison of the <code>PFilePath</code> names of the files.
@return
relative rank of the file paths.
*/
Comparison Compare(
const PObject & obj ///< Other file to compare against.
) const;
//@}
/**@name Overrides from class PChannel */
//@{
/**Open the current file in the specified mode and with
the specified options. If the file object already has an open file then
it is closed.
If there has not been a filename attached to the file object (via
<code>SetFilePath()</code>, the <code>name</code> parameter or a previous
open) then a new unique temporary filename is generated.
@return
true if the file was successfully opened.
*/
virtual PBoolean Open(
OpenMode mode = ReadWrite, // Mode in which to open the file.
int opts = ModeDefault // Options for open operation.
);
/**Open the specified file name in the specified mode and with
the specified options. If the file object already has an open file then
it is closed.
Note: if <code>mode</code> is StandardInput, StandardOutput or StandardError,
then the <code>name</code> parameter is ignored.
@return
true if the file was successfully opened.
*/
virtual PBoolean Open(
const PFilePath & name, // Name of file to open.
OpenMode mode = ReadWrite, // Mode in which to open the file.
int opts = ModeDefault // <code>OpenOptions</code> enum# for open operation.
);
/** Close the channel, shutting down the link to the data source.
@return true if the channel successfully closed.
*/
virtual PBoolean Close();
/**Low level read from the memory file channel. The read timeout is
ignored. The GetLastReadCount() function returns the actual number
of bytes read.
The GetErrorCode() function should be consulted after Read() returns
false to determine what caused the failure.
@return
true indicates that at least one character was read from the channel.
false means no bytes were read due to timeout or some other I/O error.
*/
virtual PBoolean Read(
void * buf, ///< Pointer to a block of memory to receive the read bytes.
PINDEX len ///< Maximum number of bytes to read into the buffer.
);
/**Low level write to the memory file channel. The write timeout is
ignored. The GetLastWriteCount() function returns the actual number
of bytes written.
The GetErrorCode() function should be consulted after Write() returns
false to determine what caused the failure.
@return true if at least len bytes were written to the channel.
*/
virtual PBoolean Write(
const void * buf, ///< Pointer to a block of memory to write.
PINDEX len ///< Number of bytes to write.
);
//@}
/**@name Overrides from class PFile */
//@{
/**Get the current size of the file.
The size of the file corresponds to the size of the data array.
@return
length of file in bytes.
*/
virtual off_t GetLength() const;
/**Set the size of the file, padding with 0 bytes if it would require
expanding the file, or truncating it if being made shorter.
@return
true if the file size was changed to the length specified.
*/
virtual PBoolean SetLength(
off_t len ///< New length of file.
);
/**Set the current active position in the file for the next read or write
operation. The <code>pos</code> variable is a signed number which is
added to the specified origin. For <code>origin == PFile::Start</code>
only positive values for <code>pos</code> are meaningful. For
<code>origin == PFile::End</code> only negative values for
<code>pos</code> are meaningful.
@return
true if the new file position was set.
*/
virtual PBoolean SetPosition(
off_t pos, ///< New position to set.
FilePositionOrigin origin = Start ///< Origin for position change.
);
/**Get the current active position in the file for the next read or write
operation.
@return
current file position relative to start of file.
*/
virtual off_t GetPosition() const;
//@}
/**@name Overrides from class PFile */
//@{
/**Get the memory data the file has operated with.
*/
const PBYTEArray & GetData() const { return m_data; }
//@}
protected:
PBYTEArray m_data;
off_t m_position;
};
#endif // PTLIB_PMEMFILE_H
// End of File ///////////////////////////////////////////////////////////////
|