2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2002 Simon Peter, <dn.tlp@gmx.net>, et al.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * fprovide.cpp - File provider class framework, by Simon Peter <dn.tlp@gmx.net>
28 /***** CFileProvider *****/
30 bool CFileProvider::extension(const std::string &filename,
31 const std::string &extension)
33 const char *fname = filename.c_str(), *ext = extension.c_str();
35 if(strlen(fname) < strlen(ext) ||
36 stricmp(fname + strlen(fname) - strlen(ext), ext))
42 unsigned long CFileProvider::filesize(binistream *f)
44 unsigned long oldpos = f->pos(), size;
46 f->seek(0, binio::End);
48 f->seek(oldpos, binio::Set);
53 /***** CProvider_Filesystem *****/
55 binistream *CProvider_Filesystem::open(std::string filename) const
57 binifstream *f = new binifstream(filename);
60 if(f->error()) { delete f; return 0; }
62 // Open all files as little endian with IEEE floats by default
63 f->setFlag(binio::BigEndian, false); f->setFlag(binio::FloatIEEE);
68 void CProvider_Filesystem::close(binistream *f) const
70 binifstream *ff = (binifstream *)f;