protected override void Dispose(bool disposing) { if (disposing) { if (_fileSystem != null) { _fileSystem.Dispose(); _fileSystem = null; } } base.Dispose(disposing); }
public override void Connect(Uri uri, string username, string password) { string fsPath = uri.AbsolutePath; // Find the best (least specific) export string bestRoot = null; int bestMatchLength = int.MaxValue; foreach (var export in NfsFileSystem.GetExports(uri.Host)) { if (fsPath.Length >= export.Length) { int matchLength = export.Length; for (int i = 0; i < export.Length; ++i) { if (export[i] != fsPath[i]) { matchLength = i; break; } } if (matchLength < bestMatchLength) { bestRoot = export; bestMatchLength = matchLength; } } } if (bestRoot == null) { throw new IOException(string.Format(CultureInfo.InvariantCulture, "Unable to find an NFS export providing access to '{0}'", fsPath)); } _fileSystem = new NfsFileSystem(uri.Host, bestRoot); _path = fsPath.Substring(bestRoot.Length).Replace('/', '\\'); _extraInfo = uri.Fragment.TrimStart('#'); }