private void RefreshReadOnlyCheckInfoStatus()
        {
            if (!m_ReadOnlyVersionListReady)
            {
                return;
            }

            foreach (KeyValuePair <ResourceName, CheckInfo> checkInfo in m_CheckInfos)
            {
                CheckInfo ci = checkInfo.Value;
                ci.RefreshStatus(m_CurrentVariant, m_IgnoreOtherVariant);
                if (ci.Status == CheckStatus.StorageInReadOnly)
                {
                    m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, true, true));
                }
                else if (ci.Status == CheckStatus.Unavailable || ci.Status == CheckStatus.Disuse)
                {
                    // Do nothing.
                }
                else
                {
                    throw new Exception(Utility.Text.Format("Check resources '{0}' error with unknown status.", ci.ResourceName.FullName));
                }
            }

            m_ResourceComponent.OnCheckerReadOnlyResourceCheckComplete();
        }
        private CheckInfo GetOrAddCheckInfo(ResourceName resourceName)
        {
            CheckInfo checkInfo = null;

            if (m_CheckInfos.TryGetValue(resourceName, out checkInfo))
            {
                return(checkInfo);
            }

            checkInfo = new CheckInfo(resourceName);
            m_CheckInfos.Add(checkInfo.ResourceName, checkInfo);

            return(checkInfo);
        }
        private void RefreshReadWriteCheckInfoStatus()
        {
            if (!m_UpdatableVersionListReady || !m_ReadWriteVersionListReady)
            {
                return;
            }

            int  movedCount           = 0;
            int  removedCount         = 0;
            int  updateCount          = 0;
            long updateTotalLength    = 0L;
            long updateTotalZipLength = 0L;

            foreach (KeyValuePair <ResourceName, CheckInfo> checkInfo in m_CheckInfos)
            {
                CheckInfo ci = checkInfo.Value;
                ci.RefreshStatus(m_CurrentVariant, m_IgnoreOtherVariant);
                if (ci.Status == CheckStatus.StorageInReadOnly)
                {
                    if (m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].ContainsKey(ci.ResourceName))
                    {
                        m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Remove(ci.ResourceName);
                    }

                    m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, true, true));
                }
                else if (ci.Status == CheckStatus.StorageInReadWrite)
                {
                    if (ci.NeedMoveToDisk || ci.NeedMoveToFileSystem)
                    {
                        movedCount++;
                        string resourceFullName = ci.ResourceName.FullName;
                        string resourcePath     = Utility.Path.GetRegularPath(Path.Combine(m_ResourceComponent.ReadWritePath, resourceFullName));
                        if (ci.NeedMoveToDisk)
                        {
                            IFileSystem fileSystem = m_ResourceComponent.GetFileSystem(ci.ReadWriteFileSystemName, false);
                            if (!fileSystem.SaveAsFile(resourceFullName, resourcePath))
                            {
                                throw new Exception(Utility.Text.Format("Save as file '{0}' to '{1}' from file system '{2}' error.", resourceFullName, fileSystem.FullPath));
                            }

                            fileSystem.DeleteFile(resourceFullName);
                        }

                        if (ci.NeedMoveToFileSystem)
                        {
                            IFileSystem fileSystem = m_ResourceComponent.GetFileSystem(ci.FileSystemName, false);
                            if (!fileSystem.WriteFile(resourceFullName, resourcePath))
                            {
                                throw new Exception(Utility.Text.Format("Write resource '{0}' to file system '{1}' error.", resourceFullName, fileSystem.FullPath));
                            }

                            if (File.Exists(resourcePath))
                            {
                                File.Delete(resourcePath);
                            }
                        }
                    }

                    if (m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].ContainsKey(ci.ResourceName))
                    {
                        m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Remove(ci.ResourceName);
                    }
                    m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, false, true));

                    if (m_ResourceComponent.ReadWriteResourceInfoDic[ci.ResourceName.AssetCategory].ContainsKey(ci.ResourceName))
                    {
                        m_ResourceComponent.ReadWriteResourceInfoDic[ci.ResourceName.AssetCategory].Remove(ci.ResourceName);
                    }

                    m_ResourceComponent.ReadWriteResourceInfoDic[ci.ResourceName.AssetCategory].Add(ci.ResourceName, new ReadWriteResourceInfo(ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode));
                }
                else if (ci.Status == CheckStatus.Update)
                {
                    if (m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].ContainsKey(ci.ResourceName))
                    {
                        m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Remove(ci.ResourceName);
                    }

                    m_ResourceComponent.ResourceInfoDic[ci.ResourceName.AssetCategory].Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, false, false));
                    updateCount++;
                    updateTotalLength    += ci.Length;
                    updateTotalZipLength += ci.ZipLength;
                    m_ResourceComponent.OnCheckerResourceNeedUpdate(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, ci.ZipLength, ci.ZipHashCode);
                }
                else if (ci.Status == CheckStatus.Unavailable || ci.Status == CheckStatus.Disuse)
                {
                    // Do nothing.
                }
                else
                {
                    throw new Exception(Utility.Text.Format("Check resources '{0}' error with unknown status.", ci.ResourceName.FullName));
                }

                if (ci.NeedRemove)
                {
                    removedCount++;
                    if (ci.ReadWriteUseFileSystem)
                    {
                        IFileSystem fileSystem = m_ResourceComponent.GetFileSystem(ci.ReadWriteFileSystemName, false);
                        fileSystem.DeleteFile(ci.ResourceName.FullName);
                    }
                    else
                    {
                        string resourcePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceComponent.ReadWritePath, ci.ResourceName.FullName));
                        if (File.Exists(resourcePath))
                        {
                            File.Delete(resourcePath);
                        }
                    }
                }
            }

            if (movedCount > 0 || removedCount > 0)
            {
                RemoveEmptyFileSystems();
                Utility.Path.RemoveEmptyDirectory(m_ResourceComponent.ReadWritePath);
            }

            m_ResourceComponent.OnCheckerReadWriteResourceCheckComplete(movedCount, removedCount, updateCount, updateTotalLength, updateTotalZipLength);
        }