/**************************************************************************** ** libebml : parse EBML files, see http://embl.sourceforge.net/ ** ** ** ** Copyright (C) 2002-2004 Ingo Ralf Blum. All rights reserved. ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public ** License as published by the Free Software Foundation; either ** version 2.1 of the License, or (at your option) any later version. ** ** This library 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 ** Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public ** License along with this library; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information. ** ** Contact license@matroska.org if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ /*! \file \version \$Id: StdIOCallback.cpp 1094 2005-03-16 18:30:28Z robux4 $ \author Steve Lhomme \author Moritz Bunkus */ #include #include #if !defined(__GNUC__) || (__GNUC__ > 2) #include #endif // GCC2 #include "ebml/StdIOCallback.h" #include "ebml/Debug.h" #include "ebml/EbmlConfig.h" using namespace std; START_LIBEBML_NAMESPACE CRTError::CRTError(int nError, const std::string & Description) :std::runtime_error(Description+": "+strerror(nError)) ,Error(Error) { } CRTError::CRTError(const std::string & Description,int nError) :std::runtime_error(Description+": "+strerror(nError)) ,Error(Error) { } StdIOCallback::StdIOCallback(const char*Path, const open_mode aMode) { assert(Path!=0); char *Mode; switch (aMode) { case MODE_READ: Mode = "rb"; break; case MODE_SAFE: Mode = "rb+"; break; case MODE_WRITE: Mode = "wb"; break; case MODE_CREATE: Mode = "wb+"; break; default: throw 0; } File=fopen(Path,Mode); if(File==0) { #if !defined(__GNUC__) || (__GNUC__ > 2) stringstream Msg; Msg<<"Can't open stdio file \""<::max()); assert(Offset >= numeric_limits::min()); */ assert(Offset <= LONG_MAX); assert(Offset >= LONG_MIN); assert(Mode==SEEK_CUR||Mode==SEEK_END||Mode==SEEK_SET); if(fseek(File,Offset,Mode)!=0) { #if !defined(__GNUC__) || (__GNUC__ > 2) ostringstream Msg; Msg<<"Failed to seek file "< 2) stringstream Msg; Msg<<"Can't tell the current file pointer position for "< 2) stringstream Msg; Msg<<"Can't close file "<