예제 #1
0
        /// <summary>
        /// Loads the cache directory.
        /// </summary>
        /// <param name="dirPath">The dir path.</param>
        /// <remarks>The directory should have a two-level hierarchy, namespace
        /// directory and file/directory</remarks>
        public void LoadCacheDir(string dirPath)
        {
            if (!Directory.Exists(dirPath))
            {
                throw new ArgumentException(string.Format("Directory {0} doesn't exist",
                                                          dirPath), "dirPath");
            }

            _cacheDirs.Add(dirPath);
            var cacheDirInfo = new DirectoryInfo(dirPath);

            foreach (var nsDirInfo in cacheDirInfo.GetDirectories())
            {
                if (nsDirInfo.Name.StartsWith("."))
                {
                    // Ignore hidden.
                    continue;
                }
                var filesysInfos = nsDirInfo.GetFileSystemInfos();
                foreach (var filesysInfo in filesysInfos)
                {
                    if (!filesysInfo.Name.StartsWith("."))
                    {
                        if (!_registry.ContainsValue(filesysInfo.FullName))
                        {
                            AddToRegistry(nsDirInfo.Name, filesysInfo.Name, filesysInfo.FullName,
                                          false);
                        }
                    }
                }
            }
        }