Ejemplo n.º 1
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="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 LoadFile(string dirPath, string filepath, bool loadData,
                                            DirectoryStructure directory, Changelog changelog)
        {
            string path     = Path.Combine(dirPath, filepath);
            string filename = Path.GetFileName(path);

            if (loadData)
            {
                FileStream fs = new FileStream(path, FileMode.Open);
                if (changelog == null)
                {
                    return(new VersionData(filename, fs));
                }
                else
                {
                    string hash = changelog.GetCachedHash(filepath);
                    return(new VersionData(filename, fs, hash));
                }
            }
            else
            {
                string versionHash = Path.GetFileName(dirPath);
                if (changelog == null)
                {
                    return(VersionDataProxy.Create(versionHash, filepath, filename, directory));
                }
                else
                {
                    string hash = changelog.GetCachedHash(filepath);
                    return(VersionDataProxy.Create(versionHash, filepath, filename, directory, hash));
                }
            }
        }
Ejemplo n.º 2
0
 public override string GetCachedHash(string filepath)
 {
     if (changelog == null)
     {
         Load();
     }
     return(changelog.GetCachedHash(filepath));
 }
Ejemplo n.º 3
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));
            }
        }