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() }); } }
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); }
public UniversalPath(LocalPath path) { var separator = Path.DirectorySeparatorChar.ToString(); this.Value = path.AsRelativeToRoot().Replace(separator, "/"); }
public bool Equals(LocalPath other) { return(string.Equals(this.Value, other.Value, StringComparison.InvariantCultureIgnoreCase)); }