Beispiel #1
0
        public override void DumpDir(String fileSpec, TextWriter output)
        {
            if ((fileSpec == null) || (fileSpec.Length == 0))
            {
                fileSpec = "*.*";
            }
            Regex RE  = Regex(fileSpec);
            Int32 bct = 0;
            Int32 fct = 0;
            Int32 zct = 0;
            Int32 s   = 1; // current directory segment number

            while (s != 0)
            {
                Block  B  = mDir[s];
                Int32  eb = B.GetUInt16L(6);
                Int32  bp = B.GetUInt16L(8);
                Int32  sp = 10;
                UInt16 w;
                E      esw;
                while (((esw = (E)B.GetUInt16L(sp)) & E.EOS) == 0)
                {
                    Char   s1  = ((esw & E.PROT) == 0) ? '-' : 'P';
                    Char   s2  = ((esw & E.READ) == 0) ? '-' : 'R';
                    Char   s3  = ((esw & E.PERM) == 0) ? '-' : 'F';
                    Char   s4  = ((esw & E.TENT) == 0) ? '-' : 'T';
                    Char   s5  = ((esw & E.MPTY) == 0) ? '-' : 'E';
                    String fn1 = "---";
                    Radix50.TryConvert(B.GetUInt16L(sp + 2), ref fn1);
                    String fn2 = "---";
                    Radix50.TryConvert(B.GetUInt16L(sp + 4), ref fn2);
                    String ext = "---";
                    Radix50.TryConvert(B.GetUInt16L(sp + 6), ref ext);
                    Int32  len = B.GetUInt16L(sp + 8);
                    Int32  chj = B.GetUInt16L(sp + 10);
                    String cdt = "           ";
                    w = B.GetUInt16L(sp + 12);
                    if (w != 0)
                    {
                        Int32 y = ((w & 0xc000) >> 9) + (w & 0x001f) + 1972;
                        Int32 m = (w & 0x3c00) >> 10;
                        Int32 d = (w & 0x03e0) >> 5;
                        cdt = ((m >= 1) && (m <= 12) && (d >= 1) && (d <= 31)) ? String.Format("{0:D2}-{1}-{2:D4}", d, MONTHS[m], y) : "   -BAD-   ";
                    }
                    String fn = String.Concat(fn1, fn2, ".", ext);
                    if (!RE.IsMatch(fn))
                    {
                        fn = null;
                    }
                    if ((esw & E.PERM) != 0)
                    {
                        if (fn != null)
                        {
                            fct++;
                            bct += len;
                        }
                    }
                    else
                    {
                        zct += len;
                    }
                    if (fn != null)
                    {
                        Console.Out.WriteLine("{0} {1,5:D0} @ {2,-5:D0} {3}{4}{5}{6}{7} {8}", fn, len, bp, s1, s2, s3, s4, s5, cdt);
                    }
                    bp += len;
                    sp += 14 + eb;
                }
                s = B.GetUInt16L(2);
            }
            Int32 ns = mDir[1].GetUInt16L(0); // number of directory segments

            output.WriteLine(" {0:D0} Files, {1:D0} Blocks, {2:D0} Free blocks", fct, bct, zct);
            output.WriteLine(" {0:D0} Total blocks ({1:D0} Reserved, {2:D0} Directory)", mDirStart + ns * 2 + bct + zct, mDirStart, ns * 2);
        }
Beispiel #2
0
        private FileEntry FindFile(String fileSpec)
        {
            if ((fileSpec == null) || (fileSpec.Length == 0))
            {
                return(null);
            }
            Int32 p = fileSpec.IndexOf('@');

            if (p != -1)
            {
                Int32 start, count;
                if (!Int32.TryParse(fileSpec.Substring(p + 1).Trim(), out start) || !Int32.TryParse(fileSpec.Substring(0, p).Trim(), out count))
                {
                    return(null);
                }
                return(new FileEntry(fileSpec, start, count, DateTime.Now));
            }
            p = fileSpec.IndexOf('-');
            if (p != -1)
            {
                Int32 first, last;
                if (!Int32.TryParse(fileSpec.Substring(p + 1).Trim(), out last) || !Int32.TryParse(fileSpec.Substring(0, p).Trim(), out first))
                {
                    return(null);
                }
                return(new FileEntry(fileSpec, first, last - first + 1, DateTime.Now));
            }

            Regex RE = Regex(fileSpec);
            Int32 s  = 1;

            while (s != 0)
            {
                Block  seg = mDir[s];
                Int32  eb  = seg.GetUInt16L(6);
                Int32  bp  = seg.GetUInt16L(8);
                Int32  sp  = 10;
                E      esw;
                UInt16 w;
                while (((esw = (E)seg.GetUInt16L(sp)) & E.EOS) == 0)
                {
                    Int32 len = seg.GetUInt16L(sp + 8);
                    if ((esw & E.PERM) != 0)
                    {
                        String fn1 = "---";
                        Radix50.TryConvert(seg.GetUInt16L(sp + 2), ref fn1);
                        String fn2 = "---";
                        Radix50.TryConvert(seg.GetUInt16L(sp + 4), ref fn2);
                        String ext = "---";
                        Radix50.TryConvert(seg.GetUInt16L(sp + 6), ref ext);
                        String fn = String.Concat(fn1, fn2, ".", ext);
                        if (RE.IsMatch(fn))
                        {
                            w = seg.GetUInt16L(sp + 12);
                            DateTime dt = DateTime.Now;
                            if (w != 0)
                            {
                                Int32 y = ((w & 0xc000) >> 9) + (w & 0x001f) + 1972;
                                Int32 m = (w & 0x3c00) >> 10;
                                Int32 d = (w & 0x03e0) >> 5;
                                if ((m >= 1) && (m <= 12) && (d >= 1) && (d <= 31))
                                {
                                    dt = new DateTime(y, 1, 1).AddMonths(m - 1).AddDays(d - 1);
                                }
                            }
                            return(new FileEntry(String.Concat(String.Concat(fn1, fn2).TrimEnd(' '), ".", ext.TrimEnd(' ')), bp, len, dt));
                        }
                    }
                    bp += len;
                    sp += 14 + eb;
                }
                s = seg.GetUInt16L(2);
            }
            return(null);
        }
Beispiel #3
0
        public override void ListDir(String fileSpec, TextWriter output)
        {
            if ((fileSpec == null) || (fileSpec.Length == 0))
            {
                fileSpec = "*.*";
            }
            Regex RE = Regex(fileSpec);

            output.WriteLine(DateTime.Today.ToString(" dd-MMM-yyyy"));
            Block  B = mVol[1];
            UInt16 w = B.GetUInt16L(0x1d6);

            if ((w < 64000) & IsASCIIText(B, 0x01d8, 36))
            {
                Byte[] buf = new Byte[36];
                B.CopyTo(buf, 0, 0x1d8, 36);
                output.WriteLine(" System ID: {0} {1}", Encoding.ASCII.GetString(buf, 24, 12), (w == 0x2020) ? null : Radix50.Convert(w));
                output.WriteLine(" Volume ID: {0}", Encoding.ASCII.GetString(buf, 0, 12));
                output.WriteLine(" Owner    : {0}", Encoding.ASCII.GetString(buf, 12, 12));
            }
            Boolean f   = false;
            Int32   bct = 0;
            Int32   fct = 0;
            Int32   zct = 0;
            Int32   s   = 1; // current directory segment number

            while (s != 0)
            {
                Block seg = mDir[s];
                Int32 eb  = seg.GetUInt16L(6);
                Int32 bp  = seg.GetUInt16L(8);
                Int32 sp  = 10;
                E     esw;
                while (((esw = (E)seg.GetUInt16L(sp)) & E.EOS) == 0)
                {
                    String fn1 = "---";
                    Radix50.TryConvert(seg.GetUInt16L(sp + 2), ref fn1);
                    String fn2 = "---";
                    Radix50.TryConvert(seg.GetUInt16L(sp + 4), ref fn2);
                    String ext = "---";
                    Radix50.TryConvert(seg.GetUInt16L(sp + 6), ref ext);
                    Int32  len = seg.GetUInt16L(sp + 8);
                    String cdt = "           ";
                    w = seg.GetUInt16L(sp + 12);
                    if ((w != 0) && ((esw & E.PERM) != 0))
                    {
                        Int32 y = ((w & 0xc000) >> 9) + (w & 0x001f) + 1972;
                        Int32 m = (w & 0x3c00) >> 10;
                        Int32 d = (w & 0x03e0) >> 5;
                        cdt = ((m >= 1) && (m <= 12) && (d >= 1) && (d <= 31)) ? String.Format("{0:D2}-{1}-{2:D4}", d, MONTHS[m], y) : "   -BAD-   ";
                    }
                    String fn = String.Concat(fn1, fn2, ".", ext);
                    if ((esw & E.PERM) != 0)
                    {
                        if (RE.IsMatch(fn))
                        {
                            fct++;
                            bct += len;
                        }
                        else
                        {
                            fn = null;
                        }
                    }
                    else
                    {
                        fn   = "< UNUSED >";
                        zct += len;
                    }
                    if (fn != null)
                    {
                        if (f = !f)
                        {
                            output.Write("{0} {1,5:D0}{2} {3}", fn, len, ((esw & (E.PERM | E.PROT)) == (E.PERM | E.PROT)) ? 'P' : ' ', cdt);
                        }
                        else
                        {
                            output.WriteLine("    {0} {1,5:D0}{2} {3}", fn, len, ((esw & (E.PERM | E.PROT)) == (E.PERM | E.PROT)) ? 'P' : ' ', cdt);
                        }
                    }
                    bp += len;
                    sp += 14 + eb;
                }
                s = seg.GetUInt16L(2);
            }
            if (f)
            {
                output.WriteLine();
            }
            output.WriteLine(" {0:D0} Files, {1:D0} Blocks", fct, bct);
            output.WriteLine(" {0:D0} Free blocks", zct);
        }