void MpiLauncher::destroy(bool force)
{
    pid_t pid=0;
    int status=0;
    string pidFile;
    {
        ScopedMutexLock lock(_mutex);
        if (_pid == 0 || _waiting) {
            throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
                   << " MPI launcher already destroyed");
        }
        _waiting = true;
        pid = _pid;
        status = _status;
        pidFile = mpi::getLauncherPidFile(_installPath, _queryId, _launchId);

        if (pid > 0) {
            if (!force) {
                scheduleKillTimer();
            } else { // kill right away
                boost::shared_ptr<boost::asio::deadline_timer> dummyTimer;
                boost::system::error_code dummyErr;
                handleKillTimeout(dummyTimer, dummyErr);
            }
        }
        if (force) {
            _inError=true;
        }
    }
    if (pid < 0) {
        completeLaunch(-pid, pidFile, status);
        return;
    }
    bool rc = waitForExit(pid,&status);
    assert(rc); rc=rc;
    {
        ScopedMutexLock lock(_mutex);
        if (!_waiting || pid != _pid) {
             throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
                 << " MPI launcher is corrupted after collecting process exit code";
         }

        _pid = -pid;
        _status = status;

        if (_killTimer) {
            size_t n = _killTimer->cancel();
            assert(n<2); n=n;
        }
    }
    completeLaunch(pid, pidFile, status);
}
Esempio n. 2
0
void SharedFile::truncate(uint64_t size, bool force)
{
    if (!_file) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    if (_region && !force) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    _region.reset();
    if (::truncate(getName().c_str(), size) != 0) {
        int err = errno;
        throw SystemErrorException(err, REL_FILE, __FUNCTION__, __LINE__);
    }
}
Pkcs7SignedData* Pkcs7SignedDataBuilder::doFinal()
		throw (InvalidStateException, Pkcs7Exception)
{
	int rc;
	Pkcs7SignedData *ret;
	if (this->state != Pkcs7Builder::UPDATE)
	{
		throw InvalidStateException("Pkcs7SignedDataBuilder::dofinal");
	}
	rc = BIO_flush(this->p7bio);
	if (!rc)
	{
        BIO_free(this->p7bio);
		this->p7bio = NULL;
        this->state = Pkcs7Builder::NO_INIT;
        throw Pkcs7Exception(Pkcs7Exception::INTERNAL_ERROR, "Pkcs7SignedDataBuilder::dofinal", true);
	}
	rc = PKCS7_dataFinal(this->pkcs7, this->p7bio);
	if (!rc)
	{
		BIO_free(this->p7bio);
		this->p7bio = NULL;
		PKCS7_free(this->pkcs7);
		this->pkcs7 = NULL;
		this->state = Pkcs7Builder::NO_INIT;
		throw Pkcs7Exception(Pkcs7Exception::INTERNAL_ERROR, "Pkcs7SignedDataBuilder::dofinal", true);
	}
	
	this->state = Pkcs7Builder::NO_INIT;
	BIO_free(this->p7bio);
	this->p7bio = NULL;
	ret = new Pkcs7SignedData(this->pkcs7);
	this->pkcs7 = NULL;
	return ret;
}
Esempio n. 4
0
void AppLayer::OnSendResult(bool aSuccess)
{
	if(!mSending)
		throw InvalidStateException(LOCATION, "No Active Send");

	assert(mSendQueue.size() > 0);
	mSending = false;

	FunctionCodes func = mSendQueue.front()->GetFunction();	
	mSendQueue.pop_front();

	if(func == FC_CONFIRM) {
		assert(mConfirmSending);
		mConfirmSending = false;
	}
	else {
		if(aSuccess) {
			if(func == FC_UNSOLICITED_RESPONSE) mUnsolicited.OnSendSuccess();
			else mSolicited.OnSendSuccess();
		}
		else {
			if(func == FC_UNSOLICITED_RESPONSE) mUnsolicited.OnSendFailure();
			else mSolicited.OnSendFailure();
		}
	}

	this->CheckForSend();
}
Esempio n. 5
0
void MpiSlaveProxy::waitForExit(std::shared_ptr<MpiOperatorContext>& ctx)
{
    if (!_connection) {
        throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
               << "No connection to MPI slave");
    }

    LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: launchId="<<_launchId);

    MpiOperatorContext::LaunchErrorChecker errChecker =
    boost::bind(&checkTimeout,
                mpi::getTimeInSecs(),
                static_cast<double>(_MPI_SLAVE_RESPONSE_TIMEOUT),
                _1, _2);

    std::shared_ptr<scidb::ClientMessageDescription> msg = ctx->popMsg(_launchId, errChecker);
    assert(msg);

    LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: "
                  <<" ctx = " << msg->getClientContext().get()
                  <<", msg type = "<< msg->getMessageType()
                  <<", queryID = "<<msg->getQueryId());

    if (msg->getMessageType() != scidb::SYSTEM_NONE_MSG_ID) {
        throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
               << "MPI slave returned invalid status");
    }
    assert(!msg->getClientContext());
    _connection.reset();
}
 void MpiLauncher::handleKillTimeout(boost::shared_ptr<boost::asio::deadline_timer>& killTimer,
                                     const boost::system::error_code& error)
 {
     ScopedMutexLock lock(_mutex);

     if (error == boost::asio::error::operation_aborted) {
         assert(_pid < 0);
         LOG4CXX_TRACE(logger, " MPI launcher kill timer cancelled");
         return;
     }
     if (error) {
         assert(false);
         LOG4CXX_WARN(logger, "MPI launcher kill timer encountered error"<<error);
     }
     if (_pid <= 0) {
         LOG4CXX_WARN(logger, "MPI launcher kill timer cannot kill pid="<<_pid);
         return;
     }
     if (!_waiting) {
         assert(false);
         LOG4CXX_ERROR(logger, "MPI launcher kill timer cannot kill pid="<<_pid);
         throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
             << " MPI launcher process cannot be killed";
     }
     LOG4CXX_WARN(logger, "MPI launcher is about to kill group pid="<<_pid);

     // kill launcher's proc group
     MpiErrorHandler::killProc(_installPath, -_pid);
 }
Esempio n. 7
0
void LinkLayer::OnLowerLayerUp()
{
	if(mIsOnline)
		throw InvalidStateException(LOCATION, "LowerLayerUp");
	mIsOnline = true;
	if(mpUpperLayer) mpUpperLayer->OnLowerLayerUp();
}
Esempio n. 8
0
/** \brief Check whether the collection is valid.
 *
 * This function verifies that the collection is valid. If not, an
 * exception is raised. Many other functions from the various collection
 * functions are calling this function before accessing data.
 *
 * \exception InvalidStateException
 * This exception is raised if the m_valid field is currently false and
 * thus most of the collection data is considered invalid.
 */
void FileCollection::mustBeValid() const
{
    if(!m_valid)
    {
        throw InvalidStateException("Attempted to access an invalid FileCollection");
    }
}
Esempio n. 9
0
void LinkLayer::_Send(const boost::uint8_t* apData, size_t aDataLength)
{
	if(!mIsOnline)
		throw InvalidStateException(LOCATION, "LowerLayerDown");
	if(mCONFIG.UseConfirms) mpPriState->SendConfirmed(this, apData, aDataLength);
	else mpPriState->SendUnconfirmed(this, apData, aDataLength);
}
Esempio n. 10
0
void MpiSlaveProxy::sendCommand(mpi::Command& cmd, std::shared_ptr<MpiOperatorContext>& ctx)
{
    if (!_connection) {
        throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
               << "No connection to MPI slave");
    }

    // set command
    std::shared_ptr<scidb_msg::MpiSlaveCommand> cmdPtr(new scidb_msg::MpiSlaveCommand());
    cmdPtr->set_command(cmd.getCmd());

    // set args
    const std::vector<std::string>& args = cmd.getArgs();
    google::protobuf::RepeatedPtrField<std::string>* msgArgs = cmdPtr->mutable_args();
    assert(msgArgs);
    msgArgs->Reserve(args.size());
    for (std::vector<std::string>::const_iterator iter = args.begin(); iter != args.end(); ++iter) {
        cmdPtr->add_args(*iter);
    }
    // send to slave
    scidb::MessagePtr msgPtr(cmdPtr);
    boost::asio::const_buffer binary(NULL,0);
    try {
        scidb::sendAsyncClient(_connection, scidb::mtMpiSlaveCommand, msgPtr, binary);

    } catch (const scidb::SystemException& e) {
        LOG4CXX_ERROR(logger, "MpiSlaveProxy::sendCommand: "
                      << "FAILED to send MpiSlaveCommand to slave because: "
                      << e.what());
        throw;
    }
    LOG4CXX_DEBUG(logger, "MpiSlaveProxy::sendCommand: MpiSlaveCommand "
                  << cmd.toString() << " sent to slave");
}
Esempio n. 11
0
/**********************************************************************************************
 *
 * ReadReference
 *
 * Reference = EntityReference | CharacterReference ;
 *
 * CharacterReference = "&#" [0-9]+ ";" | "&#x" [0-9a-fA-F]+ ";" ;
 *
 * EntityReference = "&lt;" | "&amp;" | "&gt;" | "&quot;" | "&apos;" ;
 *
 *********************************************************************************************/
void XMLParser::ReadReference () {
    if (current == '&') ReadCharacter ();
    else throw InvalidStateException ();

    if (current == '#') {
        if (current == 'x') {
            /* hexadecimal encoded unicode character. */
            while (ReadCharacter ()) {
                // TODO ...
                if (current == ';') break;
            }

        } else {
            /* decimal encoded unicode character. */
            do {
                // TODO ...
                if (current == ';') break;
            } while (ReadCharacter ());
        }

    } else {
        /* named entity */
        do {
            // TODO ...
            if (current == ';') break;
        } while (ReadCharacter ());
    }
}
Esempio n. 12
0
//=================================================================
//	Texture3D::GetVolumeData
//---------------------------------------
void Texture3D::GetVolumeData(VolumeData &volume) const
{
	if( Bind() )
	{
		// Make sure our volume has correct data size
		// we may have to recreate it
		UInt32 ownWidth = GetWidth();
		UInt32 ownHeight = GetHeight();
		UInt32 ownDepth = GetWidth();

		if( ownWidth != volume.GetWidth()
			|| ownHeight != volume.GetHeight()
			|| ownDepth != volume.GetDepth() )
		{
			volume.Create( ownWidth, ownHeight, ownDepth );
		}


		UInt8 *volumeData = volume.GetData();

		glGetTexImage( 
			GL_TEXTURE_3D, 
			MIP_MAP_LEVEL_0,
			GL_RGBA,
			GL_UNSIGNED_BYTE,
			(GLvoid*) volumeData 
		);
	}
	else
	{
		throw InvalidStateException();
	}
}
Esempio n. 13
0
APDU MockAppLayer::Read()
{
	if(mFragments.size() == 0) throw InvalidStateException(LOCATION, "no more fragments");
	APDU frag = mFragments.front();
	frag.Interpret();
	mFragments.pop_front();
	return frag;
}
Esempio n. 14
0
	const T& Get() const {
		if (!m_data) {
			throw InvalidStateException("Object is empty.");
		}
		if (std::type_index(typeid(T)) != m_data->Type()) {
			throw std::bad_cast("Types don't match.");
		}
		return *reinterpret_cast<const T*>(m_data->Get());
	}
Esempio n. 15
0
bool ControlTaskBase::GetSelectBit()
{
	switch(mState) {
		case(SELECT): return true;
		case(OPERATE): return false;
		default:
			throw InvalidStateException(LOCATION, "INVALID");
	}
}
void MpiLauncher::getPids(vector<pid_t>& pids)
{
    ScopedMutexLock lock(_mutex);
    if (_pid <= 1) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
            << " MPI launcher is not running";
    }
    pids.push_back(_pid);
}
Esempio n. 17
0
FunctionCodes MockAppLayer::ReadFunction()
{
	if(mFragments.size() == 0) throw InvalidStateException(LOCATION, "No more fragments");
	else {
		FunctionCodes func = mFragments.front().GetFunction();
		mFragments.pop_front();
		return func;
	}
}
Esempio n. 18
0
/** \brief Define the level of compression to use by this FileEntry.
 *
 * This function saves the level of compression the library should use
 * to compress the file before saving it in the output file.
 *
 * \note
 * If the StorageMethod is set to STORED, then the compression level is
 * ignored, but it is left unchanged.
 *
 * \exception InvalidStateException
 * This function raises this exception if the specified level is out of
 * the allowed range.
 *
 * \param[in] level  The compression level to use to compress the file data.
 */
void FileEntry::setLevel(CompressionLevel level)
{
    if(level < COMPRESSION_LEVEL_DEFAULT || level > COMPRESSION_LEVEL_MAXIMUM)
    {
        throw InvalidStateException("level must be between COMPRESSION_LEVEL_DEFAULT and COMPRESSION_LEVEL_MAXIMUM");
    }
    if(isDirectory())
    {
        if(level >= COMPRESSION_LEVEL_MINIMUM)
        {
            throw InvalidStateException("directories cannot be marked with a compression level other than COMPRESSION_LEVEL_NONE (defaults will also work");
        }
        m_compression_level = COMPRESSION_LEVEL_NONE;
    }
    else
    {
        m_compression_level = level;
    }
}
Esempio n. 19
0
void SharedMemory::truncate(uint64_t size, bool force)
{
    if (!_shm) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    if (_region && !force) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    try {
        _region.reset();
        _shm->truncate(size);
    } catch(boost::interprocess::interprocess_exception &ex) {
        std::cerr << "shm::truncate error:" << ex.what() << std::endl;
        if (ex.get_error_code() !=  boost::interprocess::no_error) {
            throw SystemErrorException(ex.get_native_error(), REL_FILE, __FUNCTION__, __LINE__);
        }
        throw;
    }
}
Esempio n. 20
0
SharedFile::AccessMode SharedFile::getAccessMode() const
{
    if (_region) {
        return static_cast<AccessMode>(_region->get_mode());
    }
    if (!_file) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    return static_cast<AccessMode>(_file->get_mode());
}
Esempio n. 21
0
/** \brief Write the ZipEndOfCentralDirectory structure to a stream.
 *
 * This function writes the currently defined end of central
 * directory to disk. This entry is expected to be written at
 * the very end of a Zip archive file.
 *
 * \note
 * If the output pointer is not valid, the function will throw
 * via the various zipWrite() it uses.
 *
 * \note
 * The function does not change the output pointer of the stream
 * before writing to it.
 *
 * \exception FileCollectionException
 * This function throws this exception if the data cannot be saved. In
 * general this means there are too many entries, the size is too large
 * or the comment is more than 64Kb (some of which will be resolved with
 * Zip64 support.)
 *
 * \param[in] os  The output stream where the data is to be saved.
 */
void ZipEndOfCentralDirectory::write(std::ostream& os)
{
    /** \TODO
     * Add support for 64 bit Zip archive. This would allow for pretty
     * much all the following conditions to be dropped out.
     */
    if(m_zip_comment.length() > 65535)
    {
        throw InvalidStateException("the Zip archive comment is too large");
    }
    if(m_central_directory_entries > 65535)
    {
        throw InvalidStateException("the number of entries in the Zip archive is too large");
    }
// Solaris defines _ILP32 for 32 bit platforms
#if !defined(_ILP32)
    if(m_central_directory_size   >= 0x100000000UL
    || m_central_directory_offset >= 0x100000000L)
    {
        throw FileCollectionException("the Zip archive size or offset are too large"); // LCOV_EXCL_LINE
    }
#endif

    uint16_t const disk_number(0);
    uint16_t const central_directory_entries(m_central_directory_entries);
    uint32_t const central_directory_size(m_central_directory_size);
    uint32_t const central_directory_offset(m_central_directory_offset);
    uint16_t const comment_len(m_zip_comment.length());

    // the total number of entries, across all disks is the same in our
    // case so we use one number for both fields

    zipWrite(os, g_signature);                      // 32
    zipWrite(os, disk_number);                      // 16
    zipWrite(os, disk_number);                      // 16
    zipWrite(os, central_directory_entries);        // 16
    zipWrite(os, central_directory_entries);        // 16
    zipWrite(os, central_directory_size);           // 32
    zipWrite(os, central_directory_offset);         // 32
    zipWrite(os, comment_len);                      // 16
    zipWrite(os, m_zip_comment);                    // string
}
Esempio n. 22
0
void Hmac::update(ByteArray &data) throw (HmacException, InvalidStateException) {
	if (this->state == Hmac::NO_INIT)
	{
		throw InvalidStateException("Hmac::update");
	}
	int rc = HMAC_Update( &this->ctx, data.getDataPointer(), data.size() );
	if (!rc)
	{
		throw HmacException(HmacException::CTX_UPDATE, "Hmac::update");
	}
	this->state = Hmac::UPDATE;
}
Esempio n. 23
0
void LinkLayer::OnLowerLayerDown()
{
	if(!mIsOnline)
		throw InvalidStateException(LOCATION, "LowerLayerDown");

	if(mpTimer != NULL) this->CancelTimer();
	mIsOnline = false;
	mpPriState = PLLS_SecNotReset::Inst();
	mpSecState = SLLS_NotReset::Inst();

	if(mpUpperLayer) mpUpperLayer->OnLowerLayerDown();
}
void ClassPoll::ConfigureRequest(APDU& arAPDU)
{
	if (mClassMask == PC_INVALID) {
		throw InvalidStateException(LOCATION, "Class mask has not been set");
	}

	arAPDU.Set(FC_READ);
	if (mClassMask & PC_CLASS_0) arAPDU.DoPlaceholderWrite(Group60Var1::Inst());
	if (mClassMask & PC_CLASS_1) arAPDU.DoPlaceholderWrite(Group60Var2::Inst());
	if (mClassMask & PC_CLASS_2) arAPDU.DoPlaceholderWrite(Group60Var3::Inst());
	if (mClassMask & PC_CLASS_3) arAPDU.DoPlaceholderWrite(Group60Var4::Inst());
}
Esempio n. 25
0
/// @todo XXX TODO tigor: make it timeout ? TBD
int64_t MpiSlaveProxy::waitForStatus(std::shared_ptr<MpiOperatorContext>& ctx, bool raise)
{
    if (!_connection) {
        throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
               << "No connection to MPI slave");
    }

    LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForStatus: launchId="<<_launchId);

    MpiOperatorContext::LaunchErrorChecker errChecker =
       boost::bind(&checkLauncher, _delayForTestingInSec, _1, _2);

    std::shared_ptr<scidb::ClientMessageDescription> msg = ctx->popMsg(_launchId, errChecker);
    assert(msg);

    LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForStatus: message from client: "
                  <<" ctx = " << msg->getClientContext().get()
                  <<", msg type = "<< msg->getMessageType()
                  <<", queryID = "<<msg->getQueryId());

    if (_connection != msg->getClientContext()) {
        if (!msg->getClientContext() &&
            msg->getMessageType() == scidb::SYSTEM_NONE_MSG_ID) {
            throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
                   << "MPI slave disconnected prematurely");
        }
        throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
               << "MPI slave connection context mismatch");
    }

    if (msg->getMessageType() != scidb::mtMpiSlaveResult) {
        throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
               << "MPI slave returned invalid status");
    }

    std::shared_ptr<scidb_msg::MpiSlaveResult> result =
        std::dynamic_pointer_cast<scidb_msg::MpiSlaveResult>(msg->getRecord());
    assert(result);

    if (!result->has_status()) {
        throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
               << "MPI slave returned no status");
    }

    if (raise && result->status() != 0) {
        std::stringstream ss;
        ss << "MPI Slave Execution returned status " << result->status();
        throw (SYSTEM_EXCEPTION(SCIDB_SE_OPERATOR, SCIDB_LE_OPERATION_FAILED) << ss.str());
    }
    return result->status();
}
void FreeFormPoll::ConfigureRequest(APDU& arAPDU)
{
	LOG_BLOCK(LEV_DEBUG, "FreeFormPoll::ConfigureRequest");

	if (this->GetClassMask() == PC_INVALID) {
		throw InvalidStateException(LOCATION, "Class mask has not been set");
	}

	arAPDU.Set(FC_READ);
	std::lock_guard<std::mutex> guard{ffInputPoints_mutex_};

	if ((this->GetClassMask() & PC_CLASS_0) && ffInputPoints.size() > 0) {

		for (std::pair<apl::DataTypes, std::vector<uint32_t>> element : ffInputPoints)
		{
			if (element.second.size() <= 0)
				continue; //should not come here
			if (element.first == apl::DataTypes::DT_ANALOG) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group30Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_BINARY) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group1Var2::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_COUNTER) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group20Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_CONTROL_STATUS) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group10Var2::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_SETPOINT_STATUS) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group40Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}

		}
	}
}
Esempio n. 27
0
void AMS_Waiting::OnPartialResponse(Master* c, const APDU& arAPDU)
{
	switch(c->mpTask->OnPartialResponse(arAPDU)) {		
		case(TR_FAIL):
			this->ChangeState(c, AMS_Idle::Inst());			
			c->mpScheduledTask->OnComplete(false);
			break;
		case(TR_CONTINUE):
			c->StartTask(c->mpTask, false);
			break;
		default:
			throw InvalidStateException(LOCATION, "Tasks must return FAIL or CONTINUE in on partial responses");
	}
}
Esempio n. 28
0
istream *ZipFile::getInputStream( const string &entry_name, 
				  MatchPath matchpath ) {
  if ( ! _valid )
    throw InvalidStateException( "Attempt to use an invalid ZipFile" ) ;

  ConstEntryPointer ent = getEntry( entry_name, matchpath ) ;
  
  if ( ent == 0 )
    return 0 ;
  else
    return new ZipInputStream( _filename,	
			   static_cast< const ZipCDirEntry * >( ent.get() )->
			   getLocalHeaderOffset() + _vs.startOffset() ) ;
}
Esempio n. 29
0
void IndexedWriteIterator::SetIndex(size_t aIndex)
{
	if(mIndexSet) throw InvalidStateException(LOCATION, "Index already set");
	if(IsEnd()) throw InvalidStateException(LOCATION, "End of iteration");

	switch(mIndexMode) {
	case(IM_1B):
		if(aIndex > UInt8::Max) throw ArgumentException(LOCATION);
		UInt8::Write(mpPos, static_cast<boost::uint8_t>(aIndex));
		break;
	case(IM_2B):
		if(aIndex > UInt16LE::Max) throw ArgumentException(LOCATION);
		UInt16LE::Write(mpPos, static_cast<boost::uint16_t>(aIndex));
		break;
	case(IM_4B):
		if(aIndex > UInt32LE::Max) throw ArgumentException(LOCATION);
		UInt32LE::Write(mpPos, static_cast<boost::uint32_t>(aIndex));
		break;
	default:
		break;
	}

	mIndexSet = true;
}
Esempio n. 30
0
uint64_t SharedMemory::getSize() const
{
    if (_region) {
        return _region->get_size();
    }
    if (!_shm) {
        throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
    }
    offset_t n=0;
    bool rc = _shm->get_size(n);
    if (!rc) {
        return 0;
    }
    return static_cast<uint64_t>(n);
}