예제 #1
0
        public QAIFDataSpanInfo GetDataSpanInfo(long index)
        {
            QAIFDataSpanInfo retval = new QAIFDataSpanInfo();

            mFSi.Position = GetIndexPosition(index);
            retval.Begin  = mBRi.ReadInt64();
            retval.Length = mBRi.ReadInt64();

            return(retval);
        }
예제 #2
0
파일: Writer.cs 프로젝트: ellil4/LibQAIF
        public Writer(String path, bool append)
        {
            mPath = path;

            if (!File.Exists(path) &&
                !File.Exists(QAIF.GetDataFilename(path)))
            {
                append = false;
            }

            if (!append)
            {
                if (File.Exists(path) &&
                    File.Exists(QAIF.GetDataFilename(path)))
                {
                    File.Delete(path);
                    File.Delete(QAIF.GetDataFilename(path));
                }

                mFSi = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);

                mFSd = new FileStream(
                    QAIF.GetDataFilename(path), FileMode.CreateNew, FileAccess.Write);

                mIndexBeg  = 0;
                mDataTill  = 0;
                mItemCount = 0;
            }
            else//append
            {
                QAIFDataSpanInfo infoIdx = QAIF.GetFileSpanInfo(path);
                mIndexBeg  = infoIdx.Begin;
                mItemCount = infoIdx.Length;

                mFSi = new FileStream(path, FileMode.Append, FileAccess.ReadWrite);

                mFSd = new FileStream(
                    QAIF.GetDataFilename(path), FileMode.Append, FileAccess.Write);

                FileInfo info = new FileInfo(QAIF.GetDataFilename(path));
                mDataTill = info.Length;
            }

            mBWi = new BinaryWriter(mFSi);
            mBWd = new BinaryWriter(mFSd);

            if (!append)
            {
                mFSi.Position = 0;
                mBWi.Write(INDEX_BEG);
                mIndexBeg = INDEX_BEG;//
                mBWi.Write(mItemCount);
            }
        }
예제 #3
0
        public int GetData(ref byte[] buffer, long index)
        {
            int retval = -1;

            QAIFDataSpanInfo info = GetDataSpanInfo(index);

            mFSd.Position = info.Begin;
            retval        = mBRd.Read(buffer, 0, (int)info.Length);

            return(retval);
        }
예제 #4
0
        public static long STRIDE             = 16;//beg and len

        public static QAIFDataSpanInfo GetFileSpanInfo(String filepath)
        {
            FileStream       fs     = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            BinaryReader     br     = new BinaryReader(fs);
            QAIFDataSpanInfo retval = new QAIFDataSpanInfo();

            fs.Position   = INFOPOS_INDEX_BEG;
            retval.Begin  = br.ReadInt64();
            fs.Position   = INFOPOS_ITEM_COUNT;
            retval.Length = br.ReadInt64();

            fs.Close();
            br.Close();

            return(retval);
        }
예제 #5
0
        public Reader(String IndexFilepath)
        {
            mPath = IndexFilepath;

            QAIFDataSpanInfo info = QAIF.GetFileSpanInfo(IndexFilepath);

            mIndexBeg  = info.Begin;
            mItemCount = info.Length;

            //index
            mFSi = new FileStream(
                IndexFilepath, FileMode.Open, FileAccess.Read);
            mBRi = new BinaryReader(mFSi);

            //data
            mFSd = new FileStream(
                QAIF.GetDataFilename(IndexFilepath), FileMode.Open, FileAccess.Read);
            mBRd = new BinaryReader(mFSd);
        }