public static DsiHeader Read(AfpStream stream) { DsiHeader header = new DsiHeader(); header.flags = stream.ReadEnum <DsiFlags>(); header.command = stream.ReadEnum <DsiCommand>(); if (header.command == DsiCommand.Invalid) { return(header); } header.requestId = stream.ReadUInt16(); header.errorCodeOrWriteOffset = stream.ReadUInt32(); header.totalDataLength = stream.ReadUInt32(); header.reserved = stream.ReadUInt32(); return(header); }
public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream) { requestStream.ReadUInt8(); // Padding ushort volumeId = requestStream.ReadUInt16(); uint directoryId = requestStream.ReadUInt32(); AfpPathType pathType = requestStream.ReadEnum <AfpPathType>(); string pathName = null; switch (pathType) { case AfpPathType.kFPLongName: case AfpPathType.kFPShortName: pathName = requestStream.ReadPascalString(); break; case AfpPathType.kFPUTF8Name: pathName = requestStream.ReadUTF8StringWithHint(); break; } AfpPathType newNameType = requestStream.ReadEnum <AfpPathType>(); string newName = null; switch (newNameType) { case AfpPathType.kFPLongName: case AfpPathType.kFPShortName: newName = requestStream.ReadPascalString(); break; case AfpPathType.kFPUTF8Name: newName = requestStream.ReadUTF8StringWithHint(); break; } IAfpVolume volume = session.GetVolume(volumeId); if (volume == null) { return(AfpResultCode.FPObjectNotFound); } IStorageContainer container = null; if (directoryId == 2) { container = volume.StorageProvider; } else { container = (volume.GetNode(directoryId) as IStorageContainer); } if (container == null) { return(AfpResultCode.FPObjectNotFound); } IStorageItem renameItem = container.Content(pathName); if (renameItem == null) { return(AfpResultCode.FPObjectNotFound); } renameItem.Rename(newName); return(AfpResultCode.FPNoErr); }