static std::string getLogConfig(std::string uri)
{
    std::string localPath;

    std::string::size_type fsPos = uri.find("?fs=");
    if (std::string::npos == fsPos) {
        return localPath;
    }

    std::string IOR = uri.substr(fsPos + 4);
    CORBA::Object_var obj = ossie::corba::stringToObject(IOR);
    if (CORBA::is_nil(obj)) {
        return localPath;
    }

    CF::FileSystem_var fileSystem = CF::FileSystem::_narrow(obj);
    if (CORBA::is_nil(fileSystem)) {
        return localPath;
    }

    std::string remotePath = uri.substr(0, fsPos);
    CF::OctetSequence_var data;
    try {
        CF::File_var remoteFile = fileSystem->open(remotePath.c_str(), true);
        CORBA::ULong size = remoteFile->sizeOf();
        remoteFile->read(data, size);
    } catch (...) {
        return localPath;
    }

    std::string tempPath = remotePath;
    std::string::size_type slashPos = remotePath.find_last_of('/');
    if (std::string::npos != slashPos) {
        tempPath.erase(0, slashPos + 1);
    }
    std::fstream localFile(tempPath.c_str(), std::ios::out|std::ios::trunc);
    if (!localFile) {
        return localPath;
    }

    if (localFile.write((const char*)data->get_buffer(), data->length())) {
        localPath = tempPath;
    }
    localFile.close();

    return localPath;
}
Exemple #2
0
PRFParser::PRFParser(CF::File_ptr file)
{
    DEBUG(4, PRFParser, "In constructor.");

    unsigned long fileSize = file->sizeOf();
    CF::OctetSequence_var fileData;

    file->read(fileData, fileSize);

    unsigned char *fileBuffer = fileData->get_buffer();

    XMLDoc.Parse((const char *)fileBuffer);

    TiXmlElement *elem = XMLDoc.FirstChildElement("properties");
    if (!elem) {
	DEBUG(1, PRFParser, "Bad PRF file.");
    }

    parseFile(elem);
}
std::streambuf::int_type File_buffer::underflow()
{
    try {
        if (gptr() < egptr()) { //buffer not exhausted
            return traits_type::to_int_type(*gptr());
        }

        char *base = &buffer_.front();
        char *start = base;

        if (eback() == base) { // true when this isn't the first fill
            // Make arrangements for putback characters
            std::memmove(base, egptr() - put_back_, put_back_);
            start += put_back_;
        }

        // start is now the start of the buffer, proper.
        // Read from fptr_ in to the provided buffer
        CF::OctetSequence_var data;
        if (!CORBA::is_nil(fptr_) && (!fptr_->_non_existent())) {
            fptr_->read(data, buffer_.size() - (start - base));
        } else {
            return traits_type::eof();
        }

        if (data->length() == 0) {
            return traits_type::eof();
        }

        memcpy(start, (const char*)data->get_buffer(), data->length());

        // Set buffer pointers
        setg(base, start, start + data->length());

        return traits_type::to_int_type(*gptr());
    } catch (...) {
        return traits_type::eof();
    }
}