コード例 #1
0
        /// <summary>
        /// Loads the VersionData that contains all child elements; i.e. the root node
        /// </summary>
        /// <param name="dirPath">The absolute path to the version directory in which all files are contained</param>
        /// <param name="rootName">The filename of the root VersionData</param>
        /// <param name="loadData">Whether or not to read the files</param>
        /// <param name="directory">The content directory from which to read</param>
        /// <param name="changelog">An optional Changelog parameter to fill in hashes</param>
        /// <returns></returns>
        public static VersionData LoadTopLevelVD(string dirPath, string rootName, bool loadData,
                                                 DirectoryStructure directory, Changelog changelog = null)
        {
            VDKeyedCollection datas = GetVersionDatas(dirPath, "", loadData, directory, changelog);

            return(new VersionData(rootName, datas));
        }
コード例 #2
0
        /// <summary>
        /// Loads a folder from the file directory into a VersionData
        /// </summary>
        /// <param name="dirPath">The absolute path to the version directory in which all files are contained</param>
        /// <param name="filePath">The relative path to a file or directory from dirpath</param>
        /// <param name="filename">The name of the folder to load</param>
        /// <param name="loadData">Whether or not to read the files</param>
        /// <param name="directory">The content directory from which to read</param>
        /// <param name="changelog">An optional Changelog parameter to fill in hashes</param>
        /// <returns></returns>
        private static VersionData LoadDirectory(string dirPath, string filePath, string filename, bool loadData,
                                                 DirectoryStructure directory, Changelog changelog = null)
        {
            VDKeyedCollection datas = GetVersionDatas(dirPath, filePath, loadData, directory, changelog);

            if (changelog == null)
            {
                return(new VersionData(filename, datas));
            }
            else
            {
                string hash = changelog.GetCachedHash(filePath);
                return(new VersionData(filename, datas, hash));
            }
        }
コード例 #3
0
        /// <summary>
        /// Loads the content of a folder in the file directory to a VDKeyedCollection
        /// </summary>
        /// <param name="dirPath">The absolute path to the version directory in which all files are contained</param>
        /// <param name="filePath">The relative path to a file or directory from dirpath</param>
        /// <param name="loadData">Whether or not to read the files</param>
        /// <param name="directory">The content directory from which to read</param>
        /// <param name="changelog">An optional Changelog parameter to fill in hashes</param>
        private static VDKeyedCollection GetVersionDatas(string dirPath, string filePath, bool loadData,
                                                         DirectoryStructure directory, Changelog changelog)
        {
            string            path  = Path.Combine(dirPath, filePath);
            VDKeyedCollection datas = new VDKeyedCollection();
            //Add all the directories
            IEnumerable <string> directoryNames = System.IO.Directory.EnumerateDirectories(path).Select(Path.GetFileName);

            foreach (string dir in directoryNames)
            {
                string dp = Path.Combine(filePath, dir);
                datas.Add(LoadVersionData(dirPath, dp, loadData, directory, changelog));
            }
            //Add all the files
            IEnumerable <string> fileNames = System.IO.Directory.EnumerateFiles(path).Select(Path.GetFileName);

            foreach (string file in fileNames)
            {
                string fp = Path.Combine(filePath, file);
                datas.Add(LoadVersionData(dirPath, fp, loadData, directory, changelog));
            }
            return(datas);
        }