DBreeze.Scheme.GetPhysicalPathToTheUserTable C# (CSharp) Method

GetPhysicalPathToTheUserTable() private method

ONLY FOR INTERNAL NEEDS, lock must be handeled by outer procedure. Users must use GetTablePathFromTableName. Transactions Journal after start will try to delete RollbackFiles of the finished transactions. For this it needs to know exact pathes. For now all tables stored in one folder. Later we will have extra config file which lets to reside some of tables in the other folders. This function is an access globalizer to physical file locations by userTableName. !!!!TRAnJRNL, WHEN RESTORES ROLLBACK, MUST REFER TO Scheme trie settings in the future, FOR NOW DEFAULT
private GetPhysicalPathToTheUserTable ( string userTableName ) : string
userTableName string
return string
        internal string GetPhysicalPathToTheUserTable(string userTableName)
        {
            try
            {
                byte[] btTableName = GetUserTableNameAsByte(userTableName);
                ulong fileName = 0;

                //Getting file name
                LTrieRow row = LTrie.GetKey(btTableName, false);

                if (row.Exists)
                {
                    byte[] fullValue = row.GetFullValue(true);
                    //Can be parsed different. First protocol version is 1
                    ushort schemeProtocol = fullValue.Substring(0, 2).To_UInt16_BigEndian();

                    switch (schemeProtocol)
                    {
                        case 1:
                            fileName = fullValue.Substring(2, 8).To_UInt64_BigEndian();
                            break;
                        default:
                            throw DBreezeException.Throw(DBreezeException.eDBreezeExceptions.SCHEME_FILE_PROTOCOL_IS_UNKNOWN);
                    }
                }
                else
                    return String.Empty;

                //Getting folder

                //For now returns path inside working folder, later re-make, take into consideration mapping of DB to tother folders.

                string alternativeTableLocation = String.Empty;

                if (CheckAlternativeTableLocationsIntersections(userTableName, out alternativeTableLocation))
                {
                    if (alternativeTableLocation == String.Empty)
                    {
                        //In memory table
                        //return Path.Combine(Engine.MainFolder, fileName.ToString());
                        return "MEMORY";
                    }
                    else
                    {
                        //returning alternative folder + fileName
                        return Path.Combine(alternativeTableLocation, fileName.ToString());
                    }
                }
                else
                {
                    //Standard path (Dbreeze mainFolder + fileName)
                    return Path.Combine(Engine.MainFolder, fileName.ToString());
                }
            }
            catch (OperationCanceledException ex)
            {
                throw ex;
            }
            //catch (System.Threading.ThreadAbortException ex)
            //{
            //    //We don'T make DBisOperable = false;
            //    throw ex;
            //}
            catch (Exception ex)
            {
                this.Engine.DBisOperable = false;
                this.Engine.DBisOperableReason = "GetPhysicalPathToTheUserTable";
                throw DBreezeException.Throw(DBreezeException.eDBreezeExceptions.GENERAL_EXCEPTION_DB_NOT_OPERABLE, this.Engine.DBisOperableReason, ex);

            }
        }