Beispiel #1
0
        public DirectoryEntry SafeResolveDirectory([NotNull] AbsolutePath path, [CanBeNull] string incomingPath = null)
        {
            Guard.NotNull(path, nameof(path));

            string completePath = incomingPath ?? path.GetText();

            AssertNetworkShareExists(path, completePath);

            if (!container.ContainsVolume(path.VolumeName))
            {
                return(null);
            }

            DirectoryEntry directory = container.GetVolume(path.VolumeName);

            foreach (AbsolutePathComponent component in path.EnumerateComponents().Skip(1))
            {
                if (!directory.ContainsDirectory(component.Name))
                {
                    return(null);
                }

                directory = directory.GetDirectory(component.Name);
            }

            return(directory);
        }
        public DirectoryEntry SafeResolveDirectory([NotNull] AbsolutePath path, [CanBeNull] string incomingPath = null)
        {
            Guard.NotNull(path, nameof(path));

            string completePath = incomingPath ?? path.GetText();

            AssertNetworkShareExists(path, completePath);

            DirectoryEntry directory = root;

            foreach (AbsolutePathComponent component in path.EnumerateComponents())
            {
                if (!directory.Directories.ContainsKey(component.Name))
                {
                    return(null);
                }

                directory = directory.Directories[component.Name];
            }

            return(directory);
        }