protected virtual int DatabaseFileSize() { LocalObjectContainer localContainer = Fixture().FileSession(); localContainer.SyncFiles(); long length = new Sharpen.IO.File(localContainer.FileName()).Length(); return (int)length; }
public void ReadFileIntoDb(File fileToStore) { // #example: Store the file as a db4o-blob blob.ReadFrom(fileToStore); // #end example WaitTillDbIsFinished(); }
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); } } }
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); } } }
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)); }
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); }
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); }
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(); }
/// <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); }
/// <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); }
/// <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)); } }
/// <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 }
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; }
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)); }