/** Implementation of the File class. See the header file for more details. @file tools/sdk/cpp/src/File.cpp @author Luke Tokheim, luke@motionnode.com @version 1.4 (C) Copyright GLI Interactive LLC 2011. All rights reserved. The coded instructions, statements, computer programs, and/or related material (collectively the "Data") in these files contain unpublished information proprietary to GLI Interactive LLC, which is protected by US federal copyright law and by international treaties. The Data may not be disclosed or distributed to third parties, in whole or in part, without the prior written consent of GLI Interactive LLC. The Data is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. */ #include #ifndef MOTION_NODE_SDK_NOTHROW # include #endif // MOTION_NODE_SDK_NOTHROW namespace MotionNode { namespace SDK { File::File(const std::string & pathname) : m_input(pathname.c_str(), std::ios_base::binary | std::ios_base::in) { #ifndef MOTION_NODE_SDK_NOTHROW if (!m_input.is_open()) { throw std::runtime_error("failed to open input file stream"); } #endif //MOTION_NODE_SDK_NOTHROW } File::~File() { #ifndef MOTION_NODE_SDK_NOTHROW try { close(); } catch (std::runtime_error &) { } #else close(); #endif // MOTION_NODE_SDK_NOTHROW } void File::close() { if (m_input.is_open()) { m_input.close(); } else { #ifndef MOTION_NODE_SDK_NOTHROW throw std::runtime_error("failed to close input file stream, not open"); #endif //MOTION_NODE_SDK_NOTHROW } } }} // namespace MotionNode::SDK