UnsupportedErr
Inheritance: Err
Esempio n. 1
0
 public OutStream writeNext(Uri path, DateTime modifyTime)
 {
     if (m_zipOut == null)
     {
         throw UnsupportedErr.make("Zip not opened for writing").val;
     }
     if (path.frag() != null)
     {
         throw ArgErr.make("Path must not contain fragment: " + path).val;
     }
     if (path.queryStr() != null)
     {
         throw ArgErr.make("Path must not contain query: " + path).val;
     }
     try
     {
         string zipPath = path.ToString();
         if (zipPath.StartsWith("/"))
         {
             zipPath = zipPath.Substring(1);
         }
         ZipEntry entry = new ZipEntry(zipPath);
         entry.DateTime = new System.DateTime(modifyTime.dotnet());
         m_zipOut.PutNextEntry(entry);
         return(new ZipSysOutStream(m_zipOut));
     }
     catch (System.IO.IOException e)
     {
         throw IOErr.make(e).val;
     }
 }
Esempio n. 2
0
        public void ordered(bool v)
        {
            modify();

            if (m_map.Count != 0)
            {
                throw UnsupportedErr.make("Map not empty").val;
            }

            if (v && caseInsensitive())
            {
                throw UnsupportedErr.make("Map cannot be caseInsensitive and ordered").val;
            }

            if (ordered() == v)
            {
                return;
            }

            if (v)
            {
                m_map = new OrderedDictionary();
            }
            else
            {
                m_map = new Hashtable();
            }
        }
Esempio n. 3
0
        public new static UnsupportedErr make(string msg, Err cause)
        {
            UnsupportedErr err = new UnsupportedErr();

            make_(err, msg, cause);
            return(err);
        }
Esempio n. 4
0
        public void caseInsensitive(bool v)
        {
            modify();

            if (m_type.m_k != Sys.StrType)
            {
                throw UnsupportedErr.make("Map not keyed by string: " + m_type).val;
            }

            if (m_map.Count != 0)
            {
                throw UnsupportedErr.make("Map not empty").val;
            }

            if (v && ordered())
            {
                throw UnsupportedErr.make("Map cannot be caseInsensitive and ordered").val;
            }

            if (this.m_caseInsensitive == v)
            {
                return;
            }
            this.m_caseInsensitive = v;

            if (m_caseInsensitive)
            {
                m_map = new Hashtable(new CIEqualityComparer());
            }
            else
            {
                m_map = new Hashtable();
            }
        }
Esempio n. 5
0
        public virtual Type parameterize(Map pars)
        {
            if (this == Sys.ListType)
            {
                Type v = (Type)pars.get(FanStr.m_ascii['V']);
                if (v == null)
                {
                    throw ArgErr.make("List.parameterize - V undefined").val;
                }
                return(v.toListOf());
            }

            if (this == Sys.MapType)
            {
                Type v = (Type)pars.get(FanStr.m_ascii['V']);
                Type k = (Type)pars.get(FanStr.m_ascii['K']);
                if (v == null)
                {
                    throw ArgErr.make("Map.parameterize - V undefined").val;
                }
                if (k == null)
                {
                    throw ArgErr.make("Map.parameterize - K undefined").val;
                }
                return(new MapType(k, v));
            }

            if (this == Sys.FuncType)
            {
                Type r = (Type)pars.get(FanStr.m_ascii['R']);
                if (r == null)
                {
                    throw ArgErr.make("Map.parameterize - R undefined").val;
                }
                ArrayList p = new ArrayList();
                for (int i = 'A'; i <= 'H'; ++i)
                {
                    Type x = (Type)pars.get(FanStr.m_ascii[i]);
                    if (x == null)
                    {
                        break;
                    }
                    p.Add(x);
                }
                return(new FuncType((Type[])p.ToArray(System.Type.GetType("Fan.Sys.Type")), r));
            }

            throw UnsupportedErr.make("not generic: " + this).val;
        }
Esempio n. 6
0
 public bool finish()
 {
     if (m_zipOut == null)
     {
         throw UnsupportedErr.make("Zip not opened for writing").val;
     }
     try
     {
         m_zipOut.Finish();
         return(true);
     }
     catch (System.IO.IOException)
     {
         return(false);
     }
 }
Esempio n. 7
0
 public virtual Long readBuf(Buf buf, long n)
 {
     try
     {
         return(m_in.readBuf(buf, n));
     }
     catch (System.NullReferenceException e)
     {
         if (m_in == null)
         {
             throw UnsupportedErr.make(@typeof().qname() + " wraps null InStream").val;
         }
         else
         {
             throw e;
         }
     }
 }
Esempio n. 8
0
 public virtual InStream unread(long n)
 {
     try
     {
         m_in.unread(n);
         return(this);
     }
     catch (System.NullReferenceException e)
     {
         if (m_in == null)
         {
             throw UnsupportedErr.make(@typeof().qname() + " wraps null InStream").val;
         }
         else
         {
             throw e;
         }
     }
 }
Esempio n. 9
0
 public virtual OutStream writeBuf(Buf buf, long n)
 {
     try
     {
         m_out.writeBuf(buf, n);
         return(this);
     }
     catch (System.NullReferenceException e)
     {
         if (m_out == null)
         {
             throw UnsupportedErr.make(@typeof().qname() + " wraps null OutStream").val;
         }
         else
         {
             throw e;
         }
     }
 }
Esempio n. 10
0
 public File readNext()
 {
     if (m_zipIn == null)
     {
         throw UnsupportedErr.make("Zip not opened for reading").val;
     }
     try
     {
         ZipEntry entry = m_zipIn.GetNextEntry();
         if (entry == null)
         {
             return(null);
         }
         return(new ZipEntryFile(this, entry));
     }
     catch (System.IO.IOException e)
     {
         throw IOErr.make(e).val;
     }
 }
Esempio n. 11
0
        //////////////////////////////////////////////////////////////////////////
        // GZIP
        //////////////////////////////////////////////////////////////////////////

        public static OutStream gzipOutStream(OutStream o)
        {
            throw UnsupportedErr.make("Zip.gzipOutStream").val;
        }
Esempio n. 12
0
 public override Buf toDigest(string algorithm)
 {
     throw UnsupportedErr.make().val;
 }
Esempio n. 13
0
 public override void encode(char ch, InStream input)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Esempio n. 14
0
        //////////////////////////////////////////////////////////////////////////
        // Base64
        //////////////////////////////////////////////////////////////////////////

        public virtual string toBase64()
        {
            throw UnsupportedErr.make(@typeof() + ".toBase64").val;
        }
Esempio n. 15
0
 public override void capacity(long x)
 {
     throw UnsupportedErr.make("mmap capacity fixed").val;
 }
Esempio n. 16
0
        public override Buf hmac(string algorithm, Buf keyBuf)
        {
            // get digest algorthim
            string alg = algorithm;

            if (alg == "SHA-1")
            {
                alg = "SHA1";            // to make .NET happy
            }
            HashAlgorithm ha = HashAlgorithm.Create(alg);

            if (ha == null)
            {
                throw ArgErr.make("Unknown digest algorthm: " + algorithm).val;
            }

            // get secret key bytes
            int blockSize = 64;

            byte[] keyBytes = null;
            int    keySize  = 0;

            try
            {
                // get key bytes
                MemBuf keyMemBuf = (MemBuf)keyBuf;
                keyBytes = keyMemBuf.m_buf;
                keySize  = keyMemBuf.m_size;

                // key is greater than block size we hash it first
                if (keySize > blockSize)
                {
                    keyBytes = ha.ComputeHash(keyBytes, 0, keySize);
                    keySize  = keyBytes.Length;
                }
            }
            catch (System.InvalidCastException)
            {
                throw UnsupportedErr.make("key parameter must be memory buffer").val;
            }

            // RFC 2104:
            //   ipad = the byte 0x36 repeated B times
            //   opad = the byte 0x5C repeated B times
            //   H(K XOR opad, H(K XOR ipad, text))

            MemBuf acc = new MemBuf(1024);

            // inner digest: H(K XOR ipad, text)
            for (int i = 0; i < blockSize; ++i)
            {
                if (i < keySize)
                {
                    acc.write((byte)(keyBytes[i] ^ 0x36));
                }
                else
                {
                    acc.write((byte)0x36);
                }
            }
            acc.pipeFrom(m_buf, 0, m_size);
            byte[] innerDigest = ha.ComputeHash(acc.m_buf, 0, acc.m_size);

            // outer digest: H(K XOR opad, innerDigest)
            acc.clear();
            for (int i = 0; i < blockSize; ++i)
            {
                if (i < keySize)
                {
                    acc.write((byte)(keyBytes[i] ^ 0x5C));
                }
                else
                {
                    acc.write((byte)0x5C);
                }
            }
            acc.pipeFrom(innerDigest, 0, innerDigest.Length);

            // return result
            return(new MemBuf(ha.ComputeHash(acc.m_buf, 0, acc.m_size)));
        }
Esempio n. 17
0
 public static void make_(UnsupportedErr self, string msg)
 {
     make_(self, msg, null);
 }
Esempio n. 18
0
 public static new UnsupportedErr make(string msg, Err cause)
 {
     UnsupportedErr err = new UnsupportedErr();
       make_(err, msg, cause);
       return err;
 }
Esempio n. 19
0
 public static void make_(UnsupportedErr self)
 {
     make_(self, null);
 }
Esempio n. 20
0
 public override OutStream writeBuf(Buf buf, long n)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Esempio n. 21
0
 public virtual Buf hmac(String algorithm, Buf key)
 {
     throw UnsupportedErr.make(@typeof() + ".hmac").val;
 }
Esempio n. 22
0
        //////////////////////////////////////////////////////////////////////////
        // Digest
        //////////////////////////////////////////////////////////////////////////

        public virtual Buf toDigest(string algorithm)
        {
            throw UnsupportedErr.make(@typeof() + ".toDigest").val;
        }
Esempio n. 23
0
 public static InStream gzipInStream(InStream i)
 {
     throw UnsupportedErr.make("Zip.gzipInStream").val;
 }
Esempio n. 24
0
 public override sealed string toHex()
 {
     throw UnsupportedErr.make().val;
 }
Esempio n. 25
0
        //////////////////////////////////////////////////////////////////////////
        // OutStream
        //////////////////////////////////////////////////////////////////////////

        public override OutStream w(int v)
        {
            throw UnsupportedErr.make("binary write on StrBuf output").val;
        }
Esempio n. 26
0
 public override Buf mmap(string mode, long pos, Long size)
 {
     throw UnsupportedErr.make("ZipEntryFile.mmap").val;
 }
Esempio n. 27
0
 public override string promptPassword(string msg)
 {
     // TODO
     throw UnsupportedErr.make().val;
 }
Esempio n. 28
0
 public static void make_(UnsupportedErr self, string msg)
 {
     make_(self, msg, null);
 }
Esempio n. 29
0
        //////////////////////////////////////////////////////////////////////////
        // Hex
        //////////////////////////////////////////////////////////////////////////

        public virtual string toHex()
        {
            throw UnsupportedErr.make(@typeof() + ".toHex").val;
        }
Esempio n. 30
0
 public static void make_(UnsupportedErr self)
 {
     make_(self, null);
 }
Esempio n. 31
0
 public static void make_(UnsupportedErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Esempio n. 32
0
 public static void make_(UnsupportedErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Esempio n. 33
0
 public override File plus(Uri uri, bool checkSlash)
 {
     // TODO
     throw UnsupportedErr.make("ZipEntryFile.plus").val;
 }