MPlist plist = null;
using (FileStream stream = File.OpenRead (dblist.FullName))
{
- MStreamReader reader = new MStreamReader (stream);
- plist = new MPlist (reader);
+ plist = new MPlist (stream);
}
if (plist == null)
return;
MPlist plist = null;
using (FileStream stream = fileinfo.OpenRead ())
{
- MStreamReader reader = new MStreamReader (stream);
- plist = new MPlist (reader, 1);
+ plist = new MPlist (stream, 1);
}
if (plist != null && plist.IsPlist)
{
Val = null;
}
+ public MPlist (FileStream stream)
+ {
+ MStreamReader reader = new MStreamReader (stream);
+ MSymbol key;
+ object val;
+ bool result = reader.ReadElement (out key, out val);
+
+ Key = key;
+ Val = val;
+ if (result)
+ next = new MPlist (reader);
+ }
+
+ public MPlist (FileStream stream, int count)
+ {
+ MStreamReader reader = new MStreamReader (stream);
+ MSymbol key;
+ object val;
+ bool result = reader.ReadElement (out key, out val);
+
+ Key = key;
+ Val = val;
+ if (result && --count > 0)
+ next = new MPlist (reader, count);
+ else
+ next = new MPlist ();
+ }
+
+ public MPlist (FileStream stream, MSymbol target, MSymbol stop)
+ {
+ MStreamReader reader = new MStreamReader (stream);
+ MSymbol key;
+ object val;
+ bool result;
+
+ Key = MSymbol.nil;
+ Val = null;
+ while (true)
+ {
+ result = reader.ReadElement (out key, out val);
+ if (! result)
+ return;
+ if (key == MSymbol.plist)
+ {
+ MPlist plist = (MPlist) val;
+
+ if (plist.IsSymbol)
+ {
+ if (plist.Symbol == stop)
+ return;
+ if (plist.Symbol == target)
+ {
+ Key = target;
+ Val = val;
+ next = new MPlist ();
+ return;
+ }
+ }
+ }
+ }
+ }
+
public MPlist (MStreamReader reader)
{
MSymbol key;
using (FileStream stream = File.OpenRead ("temp.plist"))
{
- MStreamReader reader = new MStreamReader (stream);
- Console.WriteLine (new MPlist (reader));
+ Console.WriteLine (new MPlist (stream));
}
plist = new MPlist ();