Utility class meant to replace the System.IO.Path class completely. This class handles these types of paths: UNC network paths: \\server\folder UNC-specified network paths: \\?\UNC\server\folder IPv4 network paths: \\192.168.3.22\folder IPv4 network paths: \\[2001:34:23:55::34]\folder Rooted paths: /dev/cdrom0 Rooted paths: C:\folder UNC-rooted paths: \\?\C:\folder\file Fully expanded IPv6 paths
コード例 #1
0
ファイル: PathExtensions.cs プロジェクト: DotNetIO/DotNetIO
        public static bool AllowedToAccess(this Path chjailedRootPath, string otherDirectory)
        {
            var other = new Path(otherDirectory);
            // if the given non-root is empty, we are looking at a relative path
            if (String.IsNullOrEmpty(other.Info.Root))
                return true;

            // they must be on the same drive.
            if (!String.IsNullOrEmpty(chjailedRootPath.Info.DriveLetter) && other.Info.DriveLetter != chjailedRootPath.Info.DriveLetter)
                return false;

            // we do not allow access to directories outside of the specified directory.
            return other.Info.IsParentOf(chjailedRootPath.Info);
        }
コード例 #2
0
        static IEnumerable<string> GetFilterPaths(string filter)
        {
            var lastWasSubFolder = false;

            var path = new Path(filter);

            foreach (var segment in path.Segments)
            {
                if (segment == Subfolder)
                    if (!lastWasSubFolder)
                        lastWasSubFolder = true;
                    else
                        continue;
                else
                    lastWasSubFolder = false;

                yield return segment;
            }
        }