Пример #1
0
        public Boolean TryGetResourcePath(DbRecordId dbRecordId, out String resourcePath)
        {
            lock (_dic)
            {
                if (_dic.TryGetValue(dbRecordId, out resourcePath))
                {
                    if (File.Exists(resourcePath))
                    {
                        return(true);
                    }

                    Log.Warning($"File [{resourcePath}] is no more exists. Remove DbRecordId {dbRecordId} from cache.");
                    _dic.RemoveByKey(dbRecordId);
                }
            }

            if ((_mode & DbFsIndicesMode.OnRequest) != 0)
            {
                if (TryIndexRecord(dbRecordId, out resourcePath))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        private void StoreResourcePath(BilateralDictionary <DbRecordId, String> dic, DbRecordId dbRecordId, String currentPath)
        {
            if (dic.TryGetValue(dbRecordId, out var existingPath))
            {
                String existingName = Path.GetFileName(existingPath);
                String currentName  = Path.GetFileName(currentPath);

                _errorMessage.Clear();
                _errorMessage.AppendLine($"There is two files with the same DbRecordId [{dbRecordId:X8}].");
                _errorMessage.AppendLine($"Existing: {existingName} Path: {existingPath}");
                _errorMessage.AppendLine($"New: {currentName} Path: {currentPath}");
                _errorMessage.Append($"The new file [{currentName}] will replace the old one [{existingName}]. But be careful, this is probably a mistake. Only one of these files can be used by the game at the same time.");

                Log.Error(_errorMessage.ToString());
                _errorMessage.Clear();
            }

            dic.Add(dbRecordId, currentPath);
        }