2022-02-20 11:33:47 +01:00
|
|
|
package readers
|
2022-02-19 18:10:52 +01:00
|
|
|
|
|
|
|
import "_StorBackEnd/pkg/protocol"
|
|
|
|
|
2022-02-22 08:34:45 +01:00
|
|
|
// EraseFileRuleName Identifiant de cette règle
|
|
|
|
const EraseFileRuleName = "ffe_erasefile"
|
|
|
|
|
2022-02-19 18:10:52 +01:00
|
|
|
// EraseFileRule Demande de suppression d'un fichier
|
|
|
|
type EraseFileRule struct {
|
2022-02-20 11:33:47 +01:00
|
|
|
protocol.IProtocolReader
|
2022-02-19 18:10:52 +01:00
|
|
|
// Cmd Nom de la règle
|
|
|
|
Cmd string
|
|
|
|
|
|
|
|
// matcher Permet de vérifier le matching
|
|
|
|
matcher *protocol.RegexMatcher
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateEraseFileRule Création d'une instance de EraseFileRule
|
2022-02-22 08:34:45 +01:00
|
|
|
func CreateEraseFileRule(pattern string) *EraseFileRule {
|
2022-02-19 18:10:52 +01:00
|
|
|
return &EraseFileRule{
|
2022-02-22 08:34:45 +01:00
|
|
|
Cmd: EraseFileRuleName,
|
2022-02-19 18:10:52 +01:00
|
|
|
matcher: protocol.CreateRegexMatcher(pattern),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-20 12:35:05 +01:00
|
|
|
func (rule EraseFileRule) Execute(data string) string {
|
2022-02-19 18:10:52 +01:00
|
|
|
|
2022-02-20 12:35:05 +01:00
|
|
|
if rule.Match(data) {
|
|
|
|
return "Parsing : EraseFileRule command fichier supprimé"
|
2022-02-19 18:10:52 +01:00
|
|
|
} else {
|
2022-02-20 12:35:05 +01:00
|
|
|
return "Parsing : EraseFileRule command fichier non-supprimé"
|
2022-02-19 18:10:52 +01:00
|
|
|
}
|
|
|
|
}
|
2022-02-20 12:35:05 +01:00
|
|
|
|
|
|
|
func (rule EraseFileRule) Match(data string) bool {
|
|
|
|
return rule.matcher.Match(data)
|
|
|
|
}
|