Ejemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_fileSystem != null)
                {
                    _fileSystem.Dispose();
                    _fileSystem = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        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('#');
        }
Ejemplo n.º 3
0
        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('#');
        }
Ejemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_fileSystem != null)
                {
                    _fileSystem.Dispose();
                    _fileSystem = null;
                }
            }

            base.Dispose(disposing);
        }