Ejemplo n.º 1
0
    public override IEnumerable<Item> Load()
    {
        if (!IsValidConfinementItem (this)) {
            yield break;
        }

        link = new UnixSymbolicLinkInfo (File.FullName);
        if (!link.HasContents) {
            yield break;
        }

        yield return this;
        yield return Item.Resolve (Confinement,
            new FileInfo (link.GetContents ().FullName));
    }
		public override NodeType GetSymbolicLinkTargetType(string path)
		{
			UnixSymbolicLinkInfo obj;

			try
			{
				obj = new UnixSymbolicLinkInfo(path);
			}
			catch (InvalidOperationException)
			{
				/* Not a symbolic link */

				return null;
			}

			try
			{
				if (!obj.IsSymbolicLink)
				{
					return null;
				}

				var retval = obj.GetContents();

				if (retval == null)
				{
					return null;
				}

				var isDirectory = retval.IsDirectory;

				if (isDirectory)
				{
					return NodeType.Directory;
				}

				var isRegularFile = retval.IsRegularFile;

				if (isRegularFile)
				{
					return NodeType.File;
				}

				return null;
			}
			catch (OutOfMemoryException)
			{
				throw;
			}
			catch (StackOverflowException)
			{
				throw;
			}
			catch (Exception)
			{
				return null;
			}
		}