go-ipp/utils.go

28 lines
506 B
Go
Raw Normal View History

2019-03-15 15:20:02 +00:00
package ipp
import (
"fmt"
"os"
"path"
)
func ParseControlFile(jobID int, spoolDirectory string) (*Response, error) {
if spoolDirectory == "" {
spoolDirectory = "/var/spool/cups"
}
controlFilePath := path.Join(spoolDirectory, fmt.Sprintf("c%d", jobID))
if _, err := os.Stat(controlFilePath); err != nil {
return nil, err
}
controlFile, err := os.Open(controlFilePath)
if err != nil {
return nil, err
}
defer controlFile.Close()
return NewResponseDecoder(controlFile).Decode(nil)
2019-03-15 15:20:02 +00:00
}