/usr/include/CLAM/SDIFFile.hxx is in libclam-dev 1.4.0-5build1.
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 | /*
* Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
* UNIVERSITAT POMPEU FABRA
*
*
* 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 __SDIFFile__
#define __SDIFFile__
#include "SDIFType.hxx"
#include "SDIFHeader.hxx"
#include "SDIFFrame.hxx"
#include "SDIFMatrix.hxx"
#include "SDIFStorage.hxx"
#include "ByteOrder.hxx"
#ifndef WIN32
#ifdef macintosh
#include <types.h>
#include <unistd.h>
#else
#include <sys/types.h>
#include <unistd.h>
#endif
#else
#include <stdio.h>
#include <io.h>
#endif
/** Used to read or write an SDIF file. When reading, the File
* parses the whole files and passes the read Frames to a
* Storage, typically a Collection to store all in memory.
*
* Note that the Storage is responsable for the
* freeing memory of the read frames, though File
* creates them.
*
* SDIF files use BIG ENDIAN byte order for the data storage.
* SDIFFile takes care of fixing the byte order in case
* the operating system is not BIG ENDIANm, @see CLAMByteOrder
*/
namespace SDIF
{
class File
{
public:
enum Mode
{
eInput = 1, eOutput = 2, eFullDuplex = 3
};
File(const char* filename, Mode mode);
~File();
void Open(void); //open data file
void Close(void); //close data file
bool Done(void);
CLAM::TIndex Pos(void);
CLAM::TIndex Pos(CLAM::TIndex pos);
private:
bool mSkipData;
bool mFirstAccess;
char* mpName;
Mode mMode;
int mFile;
CLAM::TSize mSize;
/*
template <class T> void ReadArray(Array<T>& data) //read from data file
{
if (mFile==-1) // check if file is opened
throw Err("DataFileIO not opened");
// added (char*) typecast to compile in MCW
int size = read(mFile,(char*)data.GetPtr(),data.AllocatedSizeInBytes());
data.SetSize(size/sizeof(T));
}
template <class T> void WriteArray(const Array<T>& data) //write to data file
{
if (mFile==-1) // check if file is open
throw Err("DataFileIO not opened");
// added (char*) typecast to compile in MCW
write(mFile,(char*)data.GetPtr(),data.SizeInBytes());
}
*/
void Read(CLAM::TByte* ptr,int n);
template <class T> void TRead(T& t)
{
Read((CLAM::TByte*) &t,sizeof(T));
FixByteOrder((CLAM::TByte*) &t,1,sizeof(T));
}
void Write(const CLAM::TByte* ptr,int n);
template <class T> void TWrite(const T& t)
{
T tmp(t);
FixByteOrder((CLAM::TByte*) &tmp,1,sizeof(T));
Write((CLAM::TByte*) &tmp,sizeof(T));
}
inline void FixByteOrder(CLAM::TByte* ptr,
CLAM::TUInt32 nElems,CLAM::TUInt32 elemSize);
void Read(DataFrameHeader& header);
void Write(const DataFrameHeader& header);
void Read(FrameHeader& header);
void Write(const FrameHeader& header);
void Read(MatrixHeader& header);
void Write(const MatrixHeader& header);
void Read(OpeningsFrame& frame);
void Write(const OpeningsFrame& frame);
void Read(Matrix& matrix);
void Write(const Matrix& matrix);
void Read(TypeId& header);
void Write(const TypeId& header);
void SkipMatrixData(const Matrix& matrix);
void ReadMatrixData(Matrix& matrix);
void WriteMatrixData(const Matrix& matrix);
public:
void Read(Storage& storage);
void Write(const Storage& storage);
void Read(Frame& frame);
void Write(const Frame& frame);
private:
void _FixByteOrder(
CLAM::TByte* ptr,CLAM::TUInt32 nElems,CLAM::TUInt32 elemSize);
};
inline int File::Pos(void)
{
int pos = lseek(mFile,0,SEEK_CUR);
return pos;
}
inline int File::Pos(int pos)
{
return lseek(mFile,pos,SEEK_SET);
}
inline void File::Read(CLAM::TByte* ptr,int n)
{
if (read(mFile,(char*)ptr,n)!=n) {
throw CLAM::Err("DataFileIO read error");
}
}
inline void File::Write(const CLAM::TByte* ptr,int n)
{
if (write(mFile,(const char*)ptr,n)!=n) {
throw CLAM::Err("DataFileIO read error");
}
}
inline bool File::Done(void)
{
return Pos()>=mSize;
}
inline void File::FixByteOrder(CLAM::TByte* ptr,
CLAM::TUInt32 nElems,CLAM::TUInt32 elemSize)
{
#ifdef CLAM_LITTLE_ENDIAN
_FixByteOrder(ptr,nElems,elemSize);
#else
#ifndef CLAM_BIG_ENDIAN
#pragma message ("BYTE ORDER NOT DEFINED!")
#endif
#endif
}
}
#endif
|