StoreBackEnd/pkg/protocol/rules/readers/EraseFileRule.go

41 lines
948 B
Go
Raw Normal View History

package readers
import "_StorBackEnd/pkg/protocol"
2022-02-22 08:34:45 +01:00
// EraseFileRuleName Identifiant de cette règle
const EraseFileRuleName = "ffe_erasefile"
// EraseFileRule Demande de suppression d'un fichier
type EraseFileRule struct {
// 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 {
return &EraseFileRule{
2022-02-22 08:34:45 +01:00
Cmd: EraseFileRuleName,
matcher: protocol.CreateRegexMatcher(pattern),
}
}
func (rule EraseFileRule) GetCmd() string {
return rule.Cmd
}
func (rule EraseFileRule) Execute(data string) string {
if rule.Match(data) {
return "Parsing : EraseFileRule command fichier supprimé"
} else {
return "Parsing : EraseFileRule command fichier non-supprimé"
}
}
func (rule EraseFileRule) Match(data string) bool {
return rule.matcher.Match(data)
}