示例#1
0
        public static ServerPath FromLocalPath(LocalPath localPath)
        {
            using (var virgilHash = VirgilHash.Sha256())
            {
                var value = localPath.AsRelativeToRoot();
                value = value.Replace('\\', '_');
                value = value.Replace('/', '_');
                value = value.ToLowerInvariant();

                virgilHash.Start();
                virgilHash.Update(Encoding.UTF8.GetBytes(value));
                var hash = virgilHash.Finish();

                var name = $"/{Base32Encoding.ToString(hash).Replace("=", string.Empty)}.virgil";

                return(new ServerPath {
                    Value = name.ToLowerInvariant()
                });
            }
        }
示例#2
0
        public static LocalPath CreateFromUniversal(UniversalPath path, LocalFolderRoot root)
        {
            var rootPath = root.Value;

            var separator = Path.DirectorySeparatorChar.ToString();

            if (!root.Value.EndsWith(separator))
            {
                rootPath = rootPath + separator;
            }

            var localRelativePath = path.Value.Replace("/", separator);
            var combine           = Path.GetFullPath(rootPath + localRelativePath);

            var result = new LocalPath
            {
                Root  = root,
                Value = combine
            };

            return(result);
        }
示例#3
0
        public UniversalPath(LocalPath path)
        {
            var separator = Path.DirectorySeparatorChar.ToString();

            this.Value = path.AsRelativeToRoot().Replace(separator, "/");
        }
示例#4
0
 public bool Equals(LocalPath other)
 {
     return(string.Equals(this.Value, other.Value, StringComparison.InvariantCultureIgnoreCase));
 }