2024-01-22 10:27:06 +00: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 05:04:55 +00:00
|
|
|
func ReadServiceError() (*StringBox, error) {
|
2024-01-22 10:27:06 +00:00
|
|
|
data, err := os.ReadFile(serviceErrorPath())
|
|
|
|
if err == nil {
|
|
|
|
os.Remove(serviceErrorPath())
|
|
|
|
}
|
2024-12-10 05:04:55 +00:00
|
|
|
return wrapString(string(data)), err
|
2024-01-22 10:27:06 +00: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()
|
|
|
|
}
|