private void SymLink(rpcCracker cracker, rpcPacker packer)
{
diropargs args = new diropargs(cracker);
string path = cracker.get_String();
sattr attr = new sattr(cracker);
String createPath = FileTable.LookupFileEntry(args.DirHandle).Name + @"\" + args.FileName + ".sl";
Console.WriteLine("Symlink: {0}->{1}", createPath, path);
fhandle fh;
if ((fh = FileTable.LookupFileHandle(createPath)) == null)
fh = FileTable.Add(new FileEntry(createPath));
try
{
FileStream symlink = new FileStream(createPath, FileMode.CreateNew, FileAccess.Write);
try
{
UTF8Encoding pathUTF8 = new UTF8Encoding();
byte[] buf = pathUTF8.GetBytes(path);
symlink.Write(buf, 0, buf.Length);
packer.setUint32((uint)NFSStatus.NFS_OK);
}
finally
{
symlink.Close();
}
}
catch(IOException)
{
if (new FileInfo(createPath).Exists == true)
throw new NFSStatusException(NFSStatus.NFSERR_EXIST);
else
throw;
}
}