mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-24 01:21:30 +00:00
33 lines
605 B
Go
33 lines
605 B
Go
package libbox
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func serviceErrorPath() string {
|
|
return filepath.Join(sWorkingPath, "network_extension_error")
|
|
}
|
|
|
|
func ClearServiceError() {
|
|
os.Remove(serviceErrorPath())
|
|
}
|
|
|
|
func ReadServiceError() (string, error) {
|
|
data, err := os.ReadFile(serviceErrorPath())
|
|
if err == nil {
|
|
os.Remove(serviceErrorPath())
|
|
}
|
|
return string(data), err
|
|
}
|
|
|
|
func WriteServiceError(message string) error {
|
|
errorFile, err := os.Create(serviceErrorPath())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
errorFile.WriteString(message)
|
|
errorFile.Chown(sUserID, sGroupID)
|
|
return errorFile.Close()
|
|
}
|