// Decompiled with JetBrains decompiler // Type: Rei.Fs.FsBase // Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null // MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0 // Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll using Microsoft.VisualBasic.CompilerServices; using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Reflection; using System.Text; namespace Rei.Fs { [Serializable] public abstract class FsBase { private static SslProtocols pAvailableTlss = SslProtocols.None; private static string p_DefClientName; private const string boundarystring = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private string p_ClientName; private string p_GroupName; private ConnectionSettingBase p_ConnectionSetting; private Uri p_BaseUri; static FsBase() { UriParserFixer.Register(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); FsBase.p_DefClientName = ((AssemblyProductAttribute) executingAssembly.GetCustomAttributes(typeof (AssemblyProductAttribute), false)[0]).Product + executingAssembly.GetName().Version.ToString(3); } public static string CreateBoundary(int seed) { Random random = new Random(seed); StringBuilder stringBuilder = new StringBuilder(70); stringBuilder.Length = 0; stringBuilder.Append("----"); while (stringBuilder.Length < 70) stringBuilder.Append("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[random.Next("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".Length)]); return stringBuilder.ToString(); } public static long ParseContentRange(string range, ref long start, ref long length, bool throwonsmall = true) { long result1 = 0; string str1 = range.Trim().ToLowerInvariant(); string Left1 = ""; long result2 = -1; int length1 = str1.IndexOf(" "); if (length1 >= 0) { Left1 = str1.Substring(0, length1); if (length1 >= str1.Length) throw new InvalidServerResponseException("Invalid Content-Range header(0)."); str1 = str1.Substring(checked (length1 + 1)).Trim(); } if (Operators.CompareString(Left1, "", false) != 0 && Operators.CompareString(Left1, "bytes", false) != 0 && Operators.CompareString(Left1, "byte", false) != 0) throw new InvalidServerResponseException("Invalid Content-Range header(1)."); int length2 = str1.IndexOf("/"); if (length2 < 0 || length2 >= str1.Length) throw new InvalidServerResponseException("Invalid Content-Range header(2)."); string Left2 = str1.Substring(0, length2).Trim(); string str2 = str1.Substring(checked (length2 + 1)).Trim(); long result3; if (Operators.CompareString(str2, "*", false) == 0) result3 = -1L; else if (!long.TryParse(str2, out result3) || result3 < 0L) throw new InvalidServerResponseException("Invalid Content-Range header. Invalid instance-length."); if (Operators.CompareString(Left2, "*", false) == 0) throw new InvalidServerResponseException("Invalid Content-Range header. \"206 Partial Content\" must specify content range."); int length3 = Left2.IndexOf("-"); if (length3 < 0 || length3 >= Left2.Length) throw new InvalidServerResponseException("Invalid Content-Range header. Invalid byte-range-resp-spec."); if (!long.TryParse(Left2.Substring(0, length3), out result1) || result1 < 0L) throw new InvalidServerResponseException("Invalid Content-Range header. Invalid first-byte-pos."); if (!long.TryParse(Left2.Substring(checked (length3 + 1)), out result2) || result2 < 0L) throw new InvalidServerResponseException("Invalid Content-Range header. Invalid last-byte-pos."); if (result2 < result1) throw new InvalidServerResponseException("Invalid Content-Range header. Inconsistent range."); if (result3 >= 0L && result2 > result3) throw new InvalidServerResponseException("Invalid Content-Range header. Inconsistent range."); if (result1 > start) throw new InvalidServerResponseException("Invalid Content-Range header. Content-Range header unmatch to Request."); if (length < 0L) { if (result3 >= 0L && result2 != checked (result3 - 1L)) throw new InvalidServerResponseException("Invalid Content-Range header. Inconsistent range."); } else if (throwonsmall && checked (start + length - 1L) > result2) throw new InvalidRangeException("not enough length"); start = result1; length = checked (result2 - result1 + 1L); return result3; } public static SslProtocols AvailableTlss() { if (FsBase.pAvailableTlss == SslProtocols.None) { SslProtocols sslProtocols = SslProtocols.None; Array values = System.Enum.GetValues(typeof (System.Security.Authentication.SslProtocols)); int num1 = 0; int num2 = checked (values.Length - 1); int index = num1; while (index <= num2) { sslProtocols |= (SslProtocols) Conversions.ToInteger(values.GetValue(index)); checked { ++index; } } FsBase.pAvailableTlss = sslProtocols & (SslProtocols.Default | SslProtocols.Tls11 | SslProtocols.Tls12); } return FsBase.pAvailableTlss; } protected FsBase(ConnectionSettingBase connectionsetting) { ServicePointManager.SecurityProtocol = (SecurityProtocolType) FsBase.AvailableTlss(); this.p_ConnectionSetting = connectionsetting; this.p_GroupName = ""; this.p_ClientName = FsBase.p_DefClientName; this.p_BaseUri = connectionsetting.TargetUri; } public virtual string UserName { get { return this.p_ConnectionSetting.UserName; } } public virtual string Password { get { return this.p_ConnectionSetting.Password; } } public virtual string ClientName { get { return this.p_ClientName; } set { this.p_ClientName = value; } } public virtual string GroupName { get { return this.p_GroupName; } set { this.p_GroupName = value; } } public virtual SecureType LastSecureType { get { return SecureType.None; } } public ConnectionSettingBase ConnectionSetting { get { return this.p_ConnectionSetting; } } protected Uri BaseUri { get { return this.p_BaseUri; } } public event EventHandler LogMessage; public void OnLogMessage(string message) { EventHandler logMessageEvent = this.LogMessageEvent; if (logMessageEvent == null) return; logMessageEvent((object) this, new LogMessageEventArgs(message)); } public abstract FsAbility Ability { get; } public bool IsCaseSensitiveFs { get { return (this.Ability & FsAbility.IgnoreCase) == FsAbility.None; } } public virtual void ResetConnection() { } public abstract ResourceInfo GetInfo(Uri targeturi); public abstract ResourceInfo[] GetEntries(ResourceId id); public virtual ResourceInfo GetInfo(ResourceId id) { return this.GetInfo(id.Uri); } public virtual ResourceInfo GetInfo(ResourceId parentid, string name) { ResourceInfo[] entries = this.GetEntries(parentid); int num1 = 0; int num2 = checked (entries.Length - 1); int index = num1; while (index <= num2) { if (Operators.CompareString(UriUtil.GetLastName(entries[index].Id.Uri), name, false) == 0) return entries[index]; checked { ++index; } } throw new RemoteResourceNotFoundException(UriUtil.CombineName(parentid.Uri, name)); } public virtual ResourceInfo GetParentInfo(ResourceId id) { return this.GetInfo(UriUtil.GetParent(id.Uri)); } public virtual ResourceInfo[] GetInfoAndEntries(Uri targeturi) { List resourceInfoList = new List(); ResourceInfo info = this.GetInfo(targeturi); resourceInfoList.Add(info); if (info.IsCollection) { ResourceInfo[] entries = this.GetEntries(info.Id); resourceInfoList.AddRange((IEnumerable) entries); } return resourceInfoList.ToArray(); } public virtual ResourceInfo[] GetInfoAndEntries(ResourceId id) { List resourceInfoList = new List(); ResourceInfo info = this.GetInfo(id); resourceInfoList.Add(info); if (info.IsCollection) { ResourceInfo[] entries = this.GetEntries(info.Id); resourceInfoList.AddRange((IEnumerable) entries); } return resourceInfoList.ToArray(); } public virtual ResourceInfo[] GetParentInfoAndEntries(ResourceId childid) { List resourceInfoList = new List(); ResourceInfo parentInfo = this.GetParentInfo(childid); resourceInfoList.Add(parentInfo); if (parentInfo.IsCollection) { ResourceInfo[] entries = this.GetEntries(parentInfo.Id); resourceInfoList.AddRange((IEnumerable) entries); } return resourceInfoList.ToArray(); } public abstract ReturnedInfo CreateCollection(ResourceId parentid, string name); public abstract void Delete(ResourceId id); public abstract ReturnedInfo Move(ResourceId id, ResourceId newparentid, string newname, bool overwrite); public abstract ReturnedInfo Copy(ResourceId id, ResourceId newparentid, string newname, bool overwrite); public abstract ReturnedInfo SetTimes(ResourceId id, DateTime lastmodifiedtime, DateTime creationtime, DateTime lastaccesstime); public abstract ReturnedInfo SetResourceInfo(ResourceInfo info, ResourceInfo original); public virtual Stream OpenRead(Uri targeturi) { ResourceId id = this.GetInfo(targeturi).Id; long start = 0; long length = -1; return this.OpenRead(id, ref start, ref length); } public abstract Stream OpenRead(ResourceId id, ref long start, ref long length); public abstract Stream OpenWrite(ResourceId parentid, string name, long length); public abstract Stream OpenWriteOver(ResourceId id, long length); public abstract Stream OpenWriteResume(ResourceId id, ref long start, ref long length); public abstract ReturnedInfo CloseWrite(Stream st); public abstract string GetLock(ResourceId id, string owner, int timeoutseconds, FsBase.LockScope scope); public abstract void ReleaseLock(ResourceId id, string locktoken); public enum LockScope { Exclusive, Shared, } } }