IsSymlink() public static method

Checks whether a file is a Cygwin symbolic link (http://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks).
There was an IO problem reading the file. Read access to the file was denied.
public static IsSymlink ( [ path ) : bool
path [ The path of the file to check.
return bool
示例#1
0
        public void TestIsSymlinkNoMatch()
        {
            using (var tempDir = new TemporaryDirectory("unit-tests"))
            {
                string normalFile = Path.Combine(tempDir, "normal");
                FileUtils.Touch(normalFile);

                CygwinUtils.IsSymlink(normalFile).Should().BeFalse();

                CygwinUtils.IsSymlink(normalFile, out string target).Should().BeFalse();
            }
        }
示例#2
0
        public void TestIsSymlinkMatch()
        {
            using (var tempDir = new TemporaryDirectory("unit-tests"))
            {
                string symlinkFile = Path.Combine(tempDir, "symlink");
                File.WriteAllBytes(symlinkFile, _symlinkBytes);
                File.SetAttributes(symlinkFile, FileAttributes.System);

                CygwinUtils.IsSymlink(symlinkFile).Should().BeTrue();

                CygwinUtils.IsSymlink(symlinkFile, out string target).Should().BeTrue();
                target.Should().Be("target");
            }
        }