public override Stream OpenInputFileStream(string path) { Stream st = null; StreamResourceInfo sr = Application.GetResourceStream(new Uri(CFilePath.removeFirstSlash(path), UriKind.Relative)); if (sr != null) { st = sr.Stream; } if (st == null) { try { CRhoFile file = new CRhoFile(); file.open(path, CRhoFile.EOpenModes.OpenReadOnly); st = file.getStream(); } catch (Exception exc) { throw new System.IO.FileNotFoundException(); } } if (st == null) { throw new System.IO.FileNotFoundException(); } return(st); }
public void open(String strPath, String strSqlScript, String strEncryptionInfo) { try { String dbURI = RHODESAPP().resolveDBFilesPath(strPath); dbURI = CFilePath.removeFirstSlash(dbURI); boolean bEncrypted = strEncryptionInfo != null && strEncryptionInfo.length() > 0; //DatabaseSecurityOptions dbso = new DatabaseSecurityOptions(bEncrypted); boolean bExist = CRhoFile.isFileExist(strPath); int res = Sqlite3.sqlite3_open(dbURI, ref m_db); if (res != Sqlite3.SQLITE_OK) { throw new DBException(res, "Could not open database file: " + strPath); } res = Sqlite3.sqlite3_exec(m_db, "PRAGMA journal_mode=PERSIST", 0, 0, 0); if (res != Sqlite3.SQLITE_OK) { Sqlite3.sqlite3_close(m_db); m_db = null; throw new DBException(res, "Cannot set journal mode to PERSIST: " + strPath); } string[] ar1 = CRhoFile.enumDirectory("db"); if (!bExist) { createSchema(strSqlScript); } Sqlite3.sqlite3_create_function(m_db, "rhoOnDeleteObjectRecord", 3, Sqlite3.SQLITE_ANY, 0, DBAdapter.SyncBlob_DeleteCallback, null, null); Sqlite3.sqlite3_create_function(m_db, "rhoOnUpdateObjectRecord", 3, Sqlite3.SQLITE_ANY, 0, DBAdapter.SyncBlob_UpdateCallback, null, null); Sqlite3.sqlite3_create_function(m_db, "rhoOnDeleteSchemaRecord", 1, Sqlite3.SQLITE_ANY, 0, DBAdapter.SyncBlob_DeleteSchemaCallback, null, null); Sqlite3.sqlite3_create_function(m_db, "rhoOnUpdateSchemaRecord", 2, Sqlite3.SQLITE_ANY, 0, DBAdapter.SyncBlob_UpdateSchemaCallback, null, null); string[] ar2 = CRhoFile.enumDirectory("db"); if (m_bPendingTransaction) { startTransaction(); } m_bPendingTransaction = false; } catch (Exception exc) { throw new DBException(exc); } finally { m_nInsideTransaction = 0; } }
public override Stream OpenInputFileStream(string path) { System.Diagnostics.Debug.WriteLine("open_file: " + path, ""); StreamResourceInfo sr = Application.GetResourceStream(new Uri(CFilePath.removeFirstSlash(path), UriKind.Relative)); if (sr == null) { throw new System.IO.FileNotFoundException(); } return(sr.Stream); }