| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package streamclient | 5 package streamclient |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | |
| 10 "io" | 9 "io" |
| 11 | 10 |
| 12 npipe "gopkg.in/natefinch/npipe.v2" | 11 npipe "gopkg.in/natefinch/npipe.v2" |
| 13 ) | 12 ) |
| 14 | 13 |
| 15 // Register POSIX-only protocols. | 14 // Register POSIX-only protocols. |
| 16 func init() { | 15 func init() { |
| 17 registerProtocol("net.pipe", newNamedPipeClient) | 16 registerProtocol("net.pipe", newNamedPipeClient) |
| 18 } | 17 } |
| 19 | 18 |
| 20 // newNamedPipeClient creates a new Client instance bound to a named pipe stream | 19 // newNamedPipeClient creates a new Client instance bound to a named pipe stream |
| 21 // server. | 20 // server. |
| 22 func newNamedPipeClient(path string) (Client, error) { | 21 func newNamedPipeClient(path string) (Client, error) { |
| 23 if path == "" { | 22 if path == "" { |
| 24 return nil, errors.New("streamclient: cannot have empty named pi
pe path") | 23 return nil, errors.New("streamclient: cannot have empty named pi
pe path") |
| 25 } | 24 } |
| 26 | 25 |
| 27 return &clientImpl{ | 26 return &clientImpl{ |
| 28 factory: func() (io.WriteCloser, error) { | 27 factory: func() (io.WriteCloser, error) { |
| 29 » » » return npipe.Dial(fmt.Sprintf(`\\.\pipe\%s`, path)) | 28 » » » return npipe.Dial(LocalNamedPipePath(path)) |
| 30 }, | 29 }, |
| 31 }, nil | 30 }, nil |
| 32 } | 31 } |
| 32 |
| 33 // LocalNamedPipePath returns the path to a local Windows named pipe named base. |
| 34 func LocalNamedPipePath(base string) string { |
| 35 return `\\.\pipe\` + base |
| 36 } |
| OLD | NEW |