Ejemplo n.º 1
0
        public static LockFile NewLockFile(string path, UtlFileAccess fileAccess)
        {
            LockFile file1 = new LockFile(fileAccess);

            file1.SetPath(path);
            return(file1);
        }
Ejemplo n.º 2
0
        public static LockFile NewLockFileLock(string path, UtlFileAccess fileAccess)
        {
            LockFile file;
            bool     flag;

            try
            {
                file = NewLockFile(path + ".lck", fileAccess);
            }
            catch (BaseException exception)
            {
                throw Error.GetError(0x1c3, exception.Message);
            }
            try
            {
                flag = file.TryLock();
            }
            catch (BaseException exception2)
            {
                throw Error.GetError(0x1c3, exception2.Message);
            }
            if (!flag)
            {
                throw Error.GetError(0x1c3, file.ToString());
            }
            return(file);
        }
Ejemplo n.º 3
0
 public override bool Load(UtlFileAccess fileAccess)
 {
     if (DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()))
     {
         bool flag2;
         try
         {
             flag2 = base.Load(fileAccess);
         }
         catch (Exception exception)
         {
             object[] add = new object[] { exception.Message, base.FileName };
             throw Error.GetError(exception, 0x1c4, 0x1b, add);
         }
         if (!flag2)
         {
             return(false);
         }
         this.FilterLoadedProperties();
         if (this.GetProperty("version").CompareTo(ThisVersion) > 0)
         {
             throw Error.GetError(0x1c5);
         }
         if (this.GetIntegerProperty("LibCore.script_format") != 0)
         {
             throw Error.GetError(0x1c5);
         }
     }
     return(true);
 }
Ejemplo n.º 4
0
 public virtual void InitParams(Database database, string baseFileName)
 {
     this.DataFileName     = baseFileName + ".data";
     this.BackupFileName   = baseFileName + ".backup";
     this.database         = database;
     this.Fa               = database.logger.GetFileAccess();
     this.CacheFileScale   = database.logger.GetCacheFileScale();
     this.CachedRowPadding = 8;
     if (this.CacheFileScale > 8)
     {
         this.CachedRowPadding = this.CacheFileScale;
     }
     if (this.InitialFreePos < this.CacheFileScale)
     {
         this.InitialFreePos = this.CacheFileScale;
     }
     this.CacheReadonly   = database.logger.PropFilesReadOnly;
     this.MaxCacheRows    = database.logger.PropCacheMaxRows;
     this.MaxCacheBytes   = database.logger.PropCacheMaxSize;
     this.MaxDataFileSize = 0x7fffffffL * this.CacheFileScale;
     this.MaxFreeBlocks   = database.logger.PropMaxFreeBlocks;
     this.DataFile        = null;
     this._shadowFile     = null;
     this.cache           = new Cache(this);
 }
Ejemplo n.º 5
0
 public Log(Database db)
 {
     this._database   = db;
     this._fa         = db.logger.GetFileAccess();
     this._fileName   = db.GetPath();
     this._properties = db.GetProperties();
 }
Ejemplo n.º 6
0
 public LibCoreProperties(string name, UtlFileAccess accessor)
 {
     this.ErrorCodes  = new int[0];
     this.ErrorKeys   = new string[0];
     this.StringProps = new Properties();
     this.FileName    = name;
     this.Fa          = accessor;
 }
Ejemplo n.º 7
0
 public LibCoreProperties(string name)
 {
     this.ErrorCodes  = new int[0];
     this.ErrorKeys   = new string[0];
     this.StringProps = new Properties();
     this.FileName    = name;
     this.Fa          = FileUtil.GetDefaultInstance();
 }
Ejemplo n.º 8
0
        public virtual bool Load(UtlFileAccess fileAccess)
        {
            if (!this.CheckFileExists())
            {
                return(false);
            }
            if (string.IsNullOrEmpty(this.FileName))
            {
                throw new FileNotFoundException(Error.GetMessage(0x1c));
            }
            string filePath = this.FileName + ".properties";

            this.StringProps.Load(filePath, fileAccess);
            return(true);
        }
Ejemplo n.º 9
0
 protected void OpenFile()
 {
     try
     {
         UtlFileAccess access = this._isDump ? FileUtil.GetDefaultInstance() : this._database.logger.GetFileAccess();
         Stream        s      = access.OpenOutputStreamElement(this.OutFile);
         this._outDescriptor = access.GetFileSync(s);
         this.FileStreamOut  = new BufferedStream(s, 0x2000);
     }
     catch (IOException exception)
     {
         object[] add = new object[] { exception.Message, this.OutFile };
         throw Error.GetError(exception, 0x1c4, 0x1a, add);
     }
 }
Ejemplo n.º 10
0
        private bool RestoreBackup()
        {
            bool flag;

            this.DeleteOrResetFreePos();
            try
            {
                UtlFileAccess fileAccess = this.database.logger.GetFileAccess();
                if (fileAccess.IsStreamElement(this.BackupFileName))
                {
                    FileArchiver.Unarchive(this.BackupFileName, this.DataFileName, fileAccess, 1);
                    return(true);
                }
                flag = false;
            }
            catch (Exception exception)
            {
                object[] add = new object[] { exception.Message, this.BackupFileName };
                throw Error.GetError(exception, 0x1c4, 0x1a, add);
            }
            return(flag);
        }
Ejemplo n.º 11
0
        public void OpenPersistence()
        {
            if (this._database.IsFilesInAssembly())
            {
                this.fileAccess = FileUtil.GetFileAccessResource();
            }
            else
            {
                this.fileAccess = FileUtil.GetDefaultInstance();
            }
            this.isStoredFileAccess = true;
            bool flag = DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType());

            this._database.DatabaseProperties = new LibCoreDatabaseProperties(this._database);
            this.IsNewDatabase = !flag || !this.fileAccess.IsStreamElement(this._database.GetPath() + ".script");
            if (this.IsNewDatabase)
            {
                string name = NewUniqueName();
                this._database.SetUniqueName(name);
                if (this._database.UrlProperties.IsPropertyTrue("ifexists"))
                {
                    throw Error.GetError(0x1d1, this._database.GetPath());
                }
                this._database.DatabaseProperties.SetUrlProperties(this._database.UrlProperties);
            }
            else
            {
                this._database.DatabaseProperties.Load(this.fileAccess);
                if (this._database.UrlProperties.IsPropertyTrue("LibCore.files_readonly"))
                {
                    this._database.DatabaseProperties.SetProperty("LibCore.files_readonly", true);
                }
                if (this._database.UrlProperties.IsPropertyTrue("readonly"))
                {
                    this._database.DatabaseProperties.SetProperty("readonly", true);
                }
            }
            this.SetVariables();
            string path = null;

            if (DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()) && !this._database.IsFilesReadOnly())
            {
                path = this._database.GetPath() + ".app.log";
            }
            this.AppLog = new SimpleLog(path, this._propEventLogLevel, this.fileAccess);
            this._database.SetReferentialIntegrity(this._propRefIntegrity);
            if (flag)
            {
                this.CheckpointRequired = false;
                this._logsStatements    = false;
                if (this._database.GetProperties().IsPropertyTrue("LibCore.lock_file") && !this._database.IsFilesReadOnly())
                {
                    this.AcquireLock(this._database.GetPath());
                }
                this.log = new Log(this._database);
                this.log.Open();
                this._logsStatements = true;
                this._loggingEnabled = this.PropLogData && !this._database.IsFilesReadOnly();
                if (this._database.GetUniqueName() == null)
                {
                    this._database.SetUniqueName(NewUniqueName());
                }
            }
        }
Ejemplo n.º 12
0
 private LockFile(UtlFileAccess fileAccess)
 {
     this._fileAccess = fileAccess;
 }