예제 #1
0
      /// <summary>Opens a stream for reading</summary>
      /// <returns></returns>
      /// <exception cref="Logic::GZipException">Unable to inititalise stream</exception>
      /// <exception cref="Logic::FileNotFoundException">File not found</exception>
      /// <exception cref="Logic::IOException">Unable to open file</exception>
      StreamPtr  XFileInfo::OpenRead() const
      {
         StreamPtr s;

         // PHYSICAL: Open file directly
         if (Source == FileSource::Physical)
         {
            // basic file stream
            s = StreamPtr(new FileStream(FullPath, FileMode::OpenExisting, FileAccess::Read));

            // X2: Wrap in encrypted stream if necessary
            if (EncryptedX2Stream::IsEncrypted(s))
               s = StreamPtr(new EncryptedX2Stream(s));

            // X3TC: Wrap in encrypted stream if necessary
            else if (EncryptedX3Stream::IsEncrypted(s))
               s = StreamPtr(new EncryptedX3Stream(s));
         }
         else
            // CATALOG: Read from .dat file
            s = StreamPtr(new DataStream(*this));

         // PCK: Wrap in GZip decompression stream
         if (FullPath.HasExtension(L".pck") || FullPath.HasExtension(L".zip"))
            s = StreamPtr(new GZipStream(s, GZipStream::Operation::Decompression));

         // Return stream
         return s;
      }
예제 #2
0
CountedPtr<OutBufferStream> OutputBuffer::StreamPtr(ostream* Ostrm_)
{
  if (!Ostrm_)
    return StreamPtr();

  return OutBufferStream::StreamPtr(this, Ostrm_);
}
예제 #3
0
  /// Open a NIF stream. The name is used for error messages.
  NIFFile(StreamPtr nif, const std::string &name)
    : filename(name)
    {
      /* Load the entire file into memory. This allows us to use
         direct pointers to the data arrays in the NIF, instead of
         individually allocating and copying each one.

         The NIF data is only stored temporarily in memory, since once
         the mesh data is loaded it is siphoned into OGRE and
         deleted. For that reason, we might improve this further and
         use a shared region/pool based allocation scheme in the
         future, especially since only one NIFFile will ever be loaded
         at any given time.
      */
      inp = StreamPtr(new BufferStream(nif));

      parse();
    }
예제 #4
0
bool OutputFormat::addStream(QString input, OutputParams outputParams)
{
    StreamPtr stream = StreamPtr(avformat_new_stream(this->m_outputContext.data(),
                                                     outputParams.codecContext()->codec),
                                 CustomDeleters::deleteStream);

    if (!stream || avcodec_copy_context(stream->codec, outputParams.codecContext().data()) != 0)
        return false;

    stream->id = outputParams.outputIndex();

    // Some formats want stream headers to be separate.
    if (this->m_outputContext->oformat->flags & AVFMT_GLOBALHEADER)
        stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;

    if (avcodec_open2(stream->codec, outputParams.codecContext()->codec, NULL) < 0)
        return false;

    this->m_streams[input] = stream;

    return true;
}
예제 #5
0
 /// <summary>Creates a catalog stream using a file as input</summary>
 /// <param name="path">The full path.</param>
 /// <param name="mode">The creation mode.</param>
 /// <param name="access">The file access.</param>
 /// <param name="share">The sharing permitted.</param>
 /// <exception cref="Logic::FileNotFoundException">File not found</exception>
 /// <exception cref="Logic::IOException">An I/O error occurred</exception>
 CatalogStream::CatalogStream(Path path, FileMode mode, FileAccess access, FileShare share)
    : StreamDecorator( StreamPtr(new FileStream(path, mode, access, share)) )
 {
 }
예제 #6
0
 /// <summary>Creates an encrypted file stream using a file as input</summary>
 /// <param name="path">The full path.</param>
 /// <param name="mode">The creation mode.</param>
 /// <param name="access">The file access.</param>
 /// <param name="share">The sharing permitted.</param>
 /// <exception cref="Logic::FileNotFoundException">File not found</exception>
 /// <exception cref="Logic::IOException">An I/O error occurred</exception>
 EncryptedX3Stream::EncryptedX3Stream(Path path, FileMode mode, FileAccess access, FileShare share)
    : StreamDecorator( StreamPtr(new FileStream(path, mode, access, share)) ), DECRYPT_KEY(0)
 {
 }
예제 #7
0
 static StreamPtr Open(Ogre::DataStreamPtr inp)
 {
     return StreamPtr(new OgreStream(inp));
 }