Exemplo n.º 1
0
        public IndexedFS(Filesystem msys)
        {
            _msys = msys;
            if (!msys.EnumFiles().GetEnumerator().MoveNext())
            {
            //Create index
                msys.AllocSpace(0,512);
                FStream mstream = new FStream(0, msys);
                BinaryWriter mwriter = new BinaryWriter(mstream);

                mwriter.Write(filemappings.Count);
                cval++;
            }
            FStream fstr = new FStream(0, msys);
            BinaryReader mreader = new BinaryReader(fstr);
            int count = mreader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                if (mreader.ReadBoolean())
                {
                    filemappings.Add(mreader.ReadString(), mreader.ReadInt64());
                }
                else
                {
                    dirmappings.Add(mreader.ReadString(), mreader.ReadInt64());

                }

                cval++;
            }
        }
Exemplo n.º 2
0
 public ObservableStream(long fid, Filesystem msys)
 {
     _msys = msys;
     _fid = fid;
     lock (msys)
     {
         _basestream = new FStream(fid, msys);
     }
 }
Exemplo n.º 3
0
        public void Commit()
        {
            lock (dirmappings)
            {
                lock (filemappings)
                {
                    lock (_msys)
                    {
                        FStream bstr = new FStream(0, _msys);
                        BinaryWriter mwriter = new BinaryWriter(bstr);
                        mwriter.Write(filemappings.Count+dirmappings.Count);

                        foreach (KeyValuePair<string, long> et in filemappings)
                        {
                            mwriter.Write(true);
                            mwriter.Write(et.Key);
                            mwriter.Write(et.Value);
                        }
                        foreach (KeyValuePair<string, long> et in dirmappings)
                        {
                            mwriter.Write(false);
                            mwriter.Write(et.Key);
                            mwriter.Write(et.Value);

                        }
                        _msys.Commit();
                    }
                }
            }
        }