// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2006 Jonathan Pryor
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
{
}
- internal UnixSymbolicLinkInfo (string path, Stat stat)
+ internal UnixSymbolicLinkInfo (string path, Native.Stat stat)
: base (path, stat)
{
}
get {return UnixPath.GetFileName (FullPath);}
}
+ [Obsolete ("Use GetContents()")]
public UnixFileSystemInfo Contents {
- get {
- return UnixFileSystemInfo.Create (ContentsPath);
- }
+ get {return GetContents ();}
}
public string ContentsPath {
}
}
+ public UnixFileSystemInfo GetContents ()
+ {
+ string path = ReadLink ();
+ return UnixFileSystemInfo.GetFileSystemEntry (
+ UnixPath.Combine (UnixPath.GetDirectoryName (FullPath),
+ ContentsPath));
+ }
+
public void CreateSymbolicLinkTo (string path)
{
- int r = Syscall.symlink (path, OriginalPath);
+ int r = Native.Syscall.symlink (path, FullName);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
public void CreateSymbolicLinkTo (UnixFileSystemInfo path)
{
- int r = Syscall.symlink (path.FullName, OriginalPath);
+ int r = Native.Syscall.symlink (path.FullName, OriginalPath);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
public override void Delete ()
{
- int r = Syscall.unlink (FullPath);
+ int r = Native.Syscall.unlink (FullPath);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
base.Refresh ();
}
- public override void SetOwner (uint owner, uint group)
+ public override void SetOwner (long owner, long group)
{
- int r = Syscall.lchown (FullPath, owner, group);
+ int r = Native.Syscall.lchown (FullPath, Convert.ToUInt32 (owner), Convert.ToUInt32 (group));
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- protected override int GetFileStatus (string path, out Stat stat)
+ protected override bool GetFileStatus (string path, out Native.Stat stat)
{
- return Syscall.lstat (path, out stat);
+ return Native.Syscall.lstat (path, out stat) == 0;
}
- // TODO: Should ReadLink be in UnixSymbolicLinkInfo?
private string ReadLink ()
{
string r = TryReadLink ();
private string TryReadLink ()
{
- return UnixPath.ReadSymbolicLink (FullPath);
+ StringBuilder sb = new StringBuilder ((int) base.Length+1);
+ int r = Native.Syscall.readlink (FullPath, sb);
+ if (r == -1)
+ return null;
+ return sb.ToString (0, r);
}
}
}