Esempio n. 1
0
		protected virtual int DatabaseFileSize()
		{
			LocalObjectContainer localContainer = Fixture().FileSession();
			localContainer.SyncFiles();
			long length = new Sharpen.IO.File(localContainer.FileName()).Length();
			return (int)length;
		}
Esempio n. 2
0
 public void ReadFileIntoDb(File fileToStore)
 {
     // #example: Store the file as a db4o-blob
     blob.ReadFrom(fileToStore);
     // #end example
     WaitTillDbIsFinished();
 }
Esempio n. 3
0
 public void ReadFileIntoDb(File fileToStore)
 {
     // #example: Store the file as a db4o-blob
     blob.ReadFrom(fileToStore);
     // #end example
     WaitTillDbIsFinished();
 }
Esempio n. 4
0
 private void Defrag(IConfiguration config)
 {
     Sharpen.IO.File origFile = new Sharpen.IO.File(GetAbsolutePath());
     if (origFile.Exists())
     {
         try
         {
             string     backupFile = GetAbsolutePath() + ".defrag.backup";
             IIdMapping mapping    = new InMemoryIdMapping();
             // new
             // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000);
             DefragmentConfig defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile
                                                                  , mapping);
             defragConfig.ForceBackupDelete(true);
             // FIXME Cloning is ugly - wrap original in Decorator within
             // DefragContext instead?
             IConfiguration clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null
                                                                                          );
             defragConfig.Db4oConfig(clonedConfig);
             Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_64
                                                              ());
         }
         catch (IOException e)
         {
             Sharpen.Runtime.PrintStackTrace(e);
         }
     }
 }
Esempio n. 5
0
 private void Defrag(IConfiguration config)
 {
     var origFile = new File(GetAbsolutePath());
     if (origFile.Exists())
     {
         try
         {
             var backupFile = GetAbsolutePath() + ".defrag.backup";
             IIdMapping mapping = new InMemoryIdMapping();
             // new
             // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000);
             var defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile
                 , mapping);
             defragConfig.ForceBackupDelete(true);
             // FIXME Cloning is ugly - wrap original in Decorator within
             // DefragContext instead?
             var clonedConfig = (IConfiguration) ((IDeepClone) config).DeepClone(null
                 );
             defragConfig.Db4oConfig(clonedConfig);
             Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_64
                 ());
         }
         catch (IOException e)
         {
             Runtime.PrintStackTrace(e);
         }
     }
 }
Esempio n. 6
0
        protected override IObjectContainer CreateDatabase(IConfiguration config)
        {
            var origFile = new File(GetAbsolutePath());

            if (origFile.Exists())
            {
                try
                {
                    var        backupFile = GetAbsolutePath() + ".defrag.backup";
                    IIdMapping mapping    = new InMemoryIdMapping();
                    // new
                    // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000);
                    var defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile
                                                            , mapping);
                    defragConfig.ForceBackupDelete(true);
                    // FIXME Cloning is ugly - wrap original in Decorator within
                    // DefragContext instead?
                    var clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null
                                                                                      );
                    defragConfig.Db4oConfig(clonedConfig);
                    Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_30
                                                                     ());
                }
                catch (IOException e)
                {
                    Runtime.PrintStackTrace(e);
                }
            }
            return(base.CreateDatabase(config));
        }
Esempio n. 7
0
		protected override IObjectContainer CreateDatabase(IConfiguration config)
		{
			Sharpen.IO.File origFile = new Sharpen.IO.File(GetAbsolutePath());
			if (origFile.Exists())
			{
				try
				{
					string backupFile = GetAbsolutePath() + ".defrag.backup";
					IIdMapping mapping = new InMemoryIdMapping();
					// new
					// BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000);
					DefragmentConfig defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile
						, mapping);
					defragConfig.ForceBackupDelete(true);
					// FIXME Cloning is ugly - wrap original in Decorator within
					// DefragContext instead?
					IConfiguration clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null
						);
					defragConfig.Db4oConfig(clonedConfig);
					Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_30
						());
				}
				catch (IOException e)
				{
					Sharpen.Runtime.PrintStackTrace(e);
				}
			}
			return base.CreateDatabase(config);
		}
Esempio n. 8
0
 private static void ReadBlob()
 {
     using (IObjectContainer container = Db4oEmbedded.OpenFile("database.db4o"))
     {
         BlobStorage blob = container.Query <BlobStorage>()[0];
         File        file = blob.ReadFromDbIntoFile();
     }
 }
        protected virtual int DatabaseFileSize()
        {
            LocalObjectContainer localContainer = Fixture().FileSession();

            localContainer.SyncFiles();
            long length = new Sharpen.IO.File(localContainer.FileName()).Length();

            return((int)length);
        }
Esempio n. 10
0
        public File ReadFromDbIntoFile()
        {
            File file = CreateTemporaryFile();

            // #example: Load a blob from a db4o-blob
            blob.WriteTo(file);
            // #end example
            WaitTillDbIsFinished();
            return(file);
        }
		private void Prepare()
		{
			Sharpen.IO.File file = new Sharpen.IO.File(TempFile());
			if (file.Exists())
			{
				file.Delete();
			}
			IObjectContainer testDB = OpenDB();
			DefragEncryptedFileTestCase.Item item = new DefragEncryptedFileTestCase.Item("richard"
				, 100);
			testDB.Store(item);
			testDB.Close();
		}
Esempio n. 12
0
		/// <summary>Deletes the directory</summary>
		/// <exception cref="System.IO.IOException"></exception>
		public static void DeleteDir(string dir)
		{
			string absolutePath = new Sharpen.IO.File(dir).GetCanonicalPath();
			Sharpen.IO.File fDir = new Sharpen.IO.File(dir);
			if (fDir.IsDirectory())
			{
				string[] files = fDir.List();
				for (int i = 0; i < files.Length; i++)
				{
					DeleteDir(Path.Combine(absolutePath, files[i]));
				}
			}
			File4.Delete(dir);
		}
Esempio n. 13
0
        private void Prepare()
        {
            Sharpen.IO.File file = new Sharpen.IO.File(TempFile());
            if (file.Exists())
            {
                file.Delete();
            }
            IObjectContainer testDB = OpenDB();

            DefragEncryptedFileTestCase.Item item = new DefragEncryptedFileTestCase.Item("richard"
                                                                                         , 100);
            testDB.Store(item);
            testDB.Close();
        }
Esempio n. 14
0
 /// <summary>Deletes the directory</summary>
 /// <exception cref="System.IO.IOException"></exception>
 public static void DeleteDir(string dir)
 {
     var absolutePath = new File(dir).GetCanonicalPath();
     var fDir = new File(dir);
     if (fDir.IsDirectory())
     {
         var files = fDir.List();
         for (var i = 0; i < files.Length; i++)
         {
             DeleteDir(Path.Combine(absolutePath, files[i]));
         }
     }
     File4.Delete(dir);
 }
Esempio n. 15
0
        /// <summary>Deletes the directory</summary>
        /// <exception cref="System.IO.IOException"></exception>
        public static void DeleteDir(string dir)
        {
            var absolutePath = new File(dir).GetCanonicalPath();
            var fDir         = new File(dir);

            if (fDir.IsDirectory())
            {
                var files = fDir.List();
                for (var i = 0; i < files.Length; i++)
                {
                    DeleteDir(Path.Combine(absolutePath, files[i]));
                }
            }
            File4.Delete(dir);
        }
Esempio n. 16
0
 /// <exception cref="System.IO.IOException"></exception>
 internal void EnsureDirExists(string path)
 {
     Sharpen.IO.File file = new Sharpen.IO.File(path);
     if (!file.Exists())
     {
         file.Mkdirs();
     }
     if (file.Exists() && file.IsDirectory())
     {
     }
     else
     {
         throw new IOException(Db4objects.Db4o.Internal.Messages.Get(37, path));
     }
 }
Esempio n. 17
0
        /// <summary>Deletes the directory</summary>
        /// <exception cref="System.IO.IOException"></exception>
        public static void DeleteDir(string dir)
        {
            string absolutePath = new Sharpen.IO.File(dir).GetCanonicalPath();

            Sharpen.IO.File fDir = new Sharpen.IO.File(dir);
            if (fDir.IsDirectory())
            {
                string[] files = fDir.List();
                for (int i = 0; i < files.Length; i++)
                {
                    DeleteDir(Path.Combine(absolutePath, files[i]));
                }
            }
            File4.Delete(dir);
        }
Esempio n. 18
0
        /// <exception cref="System.IO.IOException"></exception>
        internal void EnsureDirExists(string path)
        {
            var file = new File(path);

            if (!file.Exists())
            {
                file.Mkdirs();
            }
            if (file.Exists() && file.IsDirectory())
            {
            }
            else
            {
                throw new IOException(Messages.Get(37, path));
            }
        }
        public Db4oLibraryEnvironment(File file, File additionalAssembly)
        {
            _targetAssembly = file.GetAbsolutePath();
#if !CF && !SILVERLIGHT
            _assemblyVersion = AssemblyVersionFor(_targetAssembly);
            _baseDirectory   = IOServices.BuildTempPath("migration-domain-" + _assemblyVersion);
            _domain          = CreateDomain(SetUpBaseDirectory());
            try
            {
                SetUpAssemblyResolver();
                SetUpLegacyAdapter();
            }
            catch (Exception x)
            {
                Dispose();
                throw new Exception("Failed to setup environment for '" + _targetAssembly + "'", x);
            }
#endif
        }
Esempio n. 20
0
		public virtual void Run(string logFilePath, string statisticsFilePath)
		{
			_logFilePath = logFilePath;
			_statisticsFilePath = statisticsFilePath;
			try
			{
				OpenFiles();
				_logFileName = new Sharpen.IO.File(_logFilePath).GetName();
				Runtime.Out.Write("  Creating statistics for " + _logFileName + "  ...   ");
				long start = Runtime.CurrentTimeMillis();
				CreateStatistics();
				long elapsed = Runtime.CurrentTimeMillis() - start;
				string elapsedString = FormatTime(elapsed);
				Runtime.Out.WriteLine("Finished! Time taken: " + elapsedString);
			}
			catch (FileNotFoundException e)
			{
				Sharpen.Runtime.PrintStackTrace(e);
			}
			CloseFiles();
		}
		public Db4oLibraryEnvironmentProvider(Sharpen.IO.File classPath)
		{
			_classPath = classPath;
		}
Esempio n. 22
0
 /// <exception cref="System.IO.IOException"></exception>
 internal void EnsureDirExists(string path)
 {
     var file = new File(path);
     if (!file.Exists())
     {
         file.Mkdirs();
     }
     if (file.Exists() && file.IsDirectory())
     {
     }
     else
     {
         throw new IOException(Messages.Get(37, path));
     }
 }
Esempio n. 23
0
		/// <exception cref="System.IO.IOException"></exception>
		internal void EnsureDirExists(string path)
		{
			Sharpen.IO.File file = new Sharpen.IO.File(path);
			if (!file.Exists())
			{
				file.Mkdirs();
			}
			if (file.Exists() && file.IsDirectory())
			{
			}
			else
			{
				throw new IOException(Db4objects.Db4o.Internal.Messages.Get(37, path));
			}
		}
Esempio n. 24
0
 public Db4oLibraryEnvironmentProvider(Sharpen.IO.File classPath)
 {
     _classPath = classPath;
 }
Esempio n. 25
0
 public Db4oNetworking(IClientServerFactory csFactory, string label)
 {
     _csFactory = csFactory != null ? csFactory : DefaultClientServerFactory();
     _file      = new Sharpen.IO.File(FilePath());
     _label     = label;
 }
        public AbstractFileBasedDb4oFixture()
        {
            string fileName = FileName();

            _databaseFile = new Sharpen.IO.File(CrossPlatformServices.DatabasePath(fileName));
        }
		public AbstractFileBasedDb4oFixture()
		{
			string fileName = FileName();
			_databaseFile = new Sharpen.IO.File(CrossPlatformServices.DatabasePath(fileName));
		}
Esempio n. 28
0
		public Db4oNetworking(IClientServerFactory csFactory, string label)
		{
			_csFactory = csFactory != null ? csFactory : DefaultClientServerFactory();
			_file = new Sharpen.IO.File(FilePath());
			_label = label;
		}