Пример #1
0
        /**
         * Not initializing db object as that will
         * be done after he has used "use database" query
         */
        public void CreateDatabase(String dbName)
        {
            String path = GetFilePath.Database(dbName);
            String conf = GetFilePath.DatabaseConf(dbName);

            if (Directory.Exists(path))
            {
                throw new Exception("Database already exists");
            }
            else
            {
                storageManager.CreateFolder(path);
            }
        }
Пример #2
0
        private void TestCreateDropFolder()
        {
            try
            {
                _logger.Message("Testing CreateDropFolder");
                Manager.CreateFolder(SampleFolder);
                Assert.IsTrue(Directory.Exists(SampleFolder));

                Manager.DropFolder(SampleFile);
                Assert.IsTrue(!Directory.Exists(SampleFolder));
            }
            catch (Exception e)
            {
                _logger.Error(e.Message);
            }
        }
Пример #3
0
        /**
         * Creates all the folders/files related to a new table
         * IMPORTANT - Presently assumed indexColumns would be empty
         * Index can be added on later using AddIndex
         */

        public void CreateTable(string dbName, string tableName, List <Column> columns)
        {
            String path    = GetFilePath.Table(dbName, tableName);
            String conf    = GetFilePath.TableConf(dbName, tableName);
            String records = GetFilePath.TableRecords(dbName, tableName);

            if (Directory.Exists(path))
            {
                throw new Exception("Table already exists");
            }
            else
            {
                table = new Table(dbName, tableName, columns, new List <Column>());
                storageManager.CreateFolder(path);                       //table folder
                Converter.ObjectToFile(table, conf);                     //schema file of table
                byte[] record = Converter.CharToBytes(new char[table.GetSizeOfRecordArray()]);
                storageManager.CreateFile(records, record.Length, true); //records file of table
            }
        }