예제 #1
0
        /// <summary>
        /// Calculate checksum for a file. The file may be a local file, or a file accessible via FTP.
        /// This function should be the primary entrypoint to calculating checksum based on a filepath or
        /// URL.
        /// </summary>
        /// <param name="filename">Full filepath or absolute FTP url</param>
        /// <param name="token">Cancellation Token</param>
        /// <returns>Checksum for the requested file.</returns>
        public string GetChecksum(string filename, CancellationToken?token = null)
        {
            Stream stream = FVFileUtil.GetContentStream(filename);

            using (stream)
            {
                return(verifier.Calculate(stream, token ?? defaultToken));
            }
        }
예제 #2
0
        public void Load(string filepath)
        {
            string contents;

            using (var stream = FVFileUtil.GetContentStream(filepath))
                using (var reader = new StreamReader(stream))
                {
                    contents = reader.ReadToEnd();
                }

            Specs = JsonConvert.DeserializeObject <Dictionary <string, string> >(contents);
        }
예제 #3
0
        public void Save(string filepath)
        {
            var contents = JsonConvert.SerializeObject(Specs, Formatting.Indented);

            FVFileUtil.WriteData(filepath, contents);
        }