@@ -227,6 +227,12 @@ type Share struct {
227227 ctx context.Context
228228}
229229
230+ func (fs * Share ) ApplicationKey () []byte {
231+ key := make ([]byte , len (fs .applicationKey ))
232+ copy (key , fs .applicationKey )
233+ return key
234+ }
235+
230236func (fs * Share ) WithContext (ctx context.Context ) * Share {
231237 if ctx == nil {
232238 panic ("nil context" )
@@ -667,13 +673,12 @@ func (fs *Share) Stat(name string) (os.FileInfo, error) {
667673 return nil , & os.PathError {Op : "stat" , Path : name , Err : err }
668674 }
669675
670- fi , err := f .fileStat , nil
671- if e := f .close (); err == nil {
672- err = e
673- }
674- if err != nil {
676+ fi := f .fileStat
677+
678+ if err := f .close (); err != nil {
675679 return nil , & os.PathError {Op : "stat" , Path : name , Err : err }
676680 }
681+
677682 return fi , nil
678683}
679684
@@ -1881,6 +1886,35 @@ func (f *File) WriteString(s string) (n int, err error) {
18811886 return f .Write ([]byte (s ))
18821887}
18831888
1889+ type encoderBytes []byte
1890+
1891+ func (e encoderBytes ) Size () int {
1892+ return len (([]byte )(e ))
1893+ }
1894+
1895+ func (e encoderBytes ) Encode (buf []byte ) {
1896+ copy (buf , ([]byte )(e ))
1897+ }
1898+
1899+ var _ Encoder = encoderBytes (nil )
1900+
1901+ // Transcieve function is used to send a request and receive a response in a single call.
1902+ func (f * File ) Transcieve (p []byte , out []byte ) (int , error ) {
1903+ output , err := f .ioctl (& IoctlRequest {
1904+ CtlCode : FSCTL_PIPE_TRANSCEIVE ,
1905+ OutputOffset : 0 ,
1906+ OutputCount : 0 ,
1907+ MaxInputResponse : 0 ,
1908+ MaxOutputResponse : uint32 (len (out )),
1909+ Flags : SMB2_0_IOCTL_IS_FSCTL ,
1910+ Input : (encoderBytes )(p ),
1911+ })
1912+ if err != nil {
1913+ return 0 , err
1914+ }
1915+ return copy (out , output ), nil
1916+ }
1917+
18841918func (f * File ) encodeSize (e Encoder ) int {
18851919 if e == nil {
18861920 return 0
0 commit comments