go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/mkdir/mkdir.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package mkdir contains the structures describing mkdir request. 6 // See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 105) for details. 7 package mkdir // import "go-hep.org/x/hep/xrootd/xrdproto/mkdir" 8 9 import ( 10 "go-hep.org/x/hep/xrootd/internal/xrdenc" 11 "go-hep.org/x/hep/xrootd/xrdfs" 12 "go-hep.org/x/hep/xrootd/xrdproto" 13 ) 14 15 // RequestID is the id of the request, it is sent as part of message. 16 // See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format. 17 const RequestID uint16 = 3008 18 19 // Options are the options to apply when path is created. 20 type Options uint8 21 22 // OptionsMakePath indicates whether directory path 23 // should be created if it does not already exist. 24 // When a directory path is created, the directory permission 25 // specified in Mode is propagated along the newly created path. 26 const OptionsMakePath Options = 1 27 28 // Request holds mkdir request parameters, such as the file path. 29 type Request struct { 30 Options Options 31 _ [13]uint8 32 Mode xrdfs.OpenMode 33 Path string 34 } 35 36 // MarshalXrd implements xrdproto.Marshaler. 37 func (req Request) MarshalXrd(wBuffer *xrdenc.WBuffer) error { 38 wBuffer.WriteU8(uint8(req.Options)) 39 wBuffer.Next(13) 40 wBuffer.WriteU16(uint16(req.Mode)) 41 wBuffer.WriteStr(req.Path) 42 return nil 43 } 44 45 // UnmarshalXrd implements xrdproto.Unmarshaler. 46 func (req *Request) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error { 47 req.Options = Options(rBuffer.ReadU8()) 48 rBuffer.Skip(13) 49 req.Mode = xrdfs.OpenMode(rBuffer.ReadU16()) 50 req.Path = rBuffer.ReadStr() 51 return nil 52 } 53 54 // ReqID implements xrdproto.Request.ReqID. 55 func (req *Request) ReqID() uint16 { return RequestID } 56 57 // ShouldSign implements xrdproto.Request.ShouldSign. 58 func (req *Request) ShouldSign() bool { return false } 59 60 // Opaque implements xrdproto.FilepathRequest.Opaque. 61 func (req *Request) Opaque() string { 62 return xrdproto.Opaque(req.Path) 63 } 64 65 // SetOpaque implements xrdproto.FilepathRequest.SetOpaque. 66 func (req *Request) SetOpaque(opaque string) { 67 xrdproto.SetOpaque(&req.Path, opaque) 68 }