2024-01-22 18:27:06 +08:00
|
|
|
package libbox
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
func serviceErrorPath() string {
|
|
|
|
return filepath.Join(sWorkingPath, "network_extension_error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ClearServiceError() {
|
|
|
|
os.Remove(serviceErrorPath())
|
|
|
|
}
|
|
|
|
|
2024-12-10 13:04:55 +08:00
|
|
|
func ReadServiceError() (*StringBox, error) {
|
2024-01-22 18:27:06 +08:00
|
|
|
data, err := os.ReadFile(serviceErrorPath())
|
|
|
|
if err == nil {
|
|
|
|
os.Remove(serviceErrorPath())
|
|
|
|
}
|
2024-12-10 13:04:55 +08:00
|
|
|
return wrapString(string(data)), err
|
2024-01-22 18:27:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|