Exemplo n.º 1
0
        public void Load(string filePath, UtlFileAccess fileAccess)
        {
            List <string> list = new List <string>();

            using (StreamReader reader = new StreamReader(fileAccess.OpenInputStreamElement(filePath)))
            {
                string str;
Label_0013:
                str = reader.ReadLine();
                if (str != null)
                {
                    list.Add(str);
                    goto Label_0013;
                }
            }
            string[] strArray = list.ToArray();
            for (int i = 0; i < strArray.Length; i++)
            {
                string str2 = strArray[i].Trim();
                if ((!string.IsNullOrEmpty(str2) && !str2.StartsWith("#")) && !str2.StartsWith("#"))
                {
                    char[]   separator = new char[] { '=' };
                    string[] strArray2 = str2.Split(separator);
                    if (strArray2.Length != 2)
                    {
                        throw new FieldAccessException(filePath);
                    }
                    base[strArray2[0]] = strArray2[1];
                }
            }
        }
Exemplo n.º 2
0
 public SimpleLog(string path, int level, UtlFileAccess fileAccess)
 {
     this._isSystem   = path == null;
     this._filePath   = path;
     this._fileAccess = fileAccess;
     this.SetLevel(level);
 }
Exemplo n.º 3
0
        public static void Archive(string infilename, string outfilename, UtlFileAccess storage, int compressionType)
        {
            GZipStream stream = null;
            bool       flag   = false;

            if (storage.IsStreamElement(infilename))
            {
                try
                {
                    byte[] buffer = new byte[0x10000];
                    using (Stream stream2 = storage.OpenInputStreamElement(infilename))
                    {
                        using (Stream stream3 = storage.OpenOutputStreamElement(outfilename))
                        {
                            int    num;
                            Stream stream4 = null;
                            if (compressionType != 0)
                            {
                                if ((compressionType - 1) > 1)
                                {
                                    throw new Exception("FileArchiver" + compressionType);
                                }
                            }
                            else
                            {
                                stream4 = stream3;
                                goto Label_0061;
                            }
                            stream = new GZipStream(stream3, CompressionMode.Compress);
Label_0061:
                            num = stream2.Read(buffer, 0, buffer.Length);
                            if (num != 0)
                            {
                                stream4.Write(buffer, 0, num);
                                goto Label_0061;
                            }
                            if (stream != null)
                            {
                                stream.Flush();
                            }
                        }
                    }
                    flag = true;
                }
                catch (Exception exception)
                {
                    try
                    {
                        if (!flag && storage.IsStreamElement(outfilename))
                        {
                            storage.RemoveElement(outfilename);
                        }
                    }
                    catch (Exception)
                    {
                    }
                    throw new IOException(exception.Message, exception);
                }
            }
        }