35 lines
816 B
Go
35 lines
816 B
Go
package readers
|
|
|
|
import "_StorBackEnd/pkg/protocol"
|
|
|
|
// EraseFileRule Demande de suppression d'un fichier
|
|
type EraseFileRule struct {
|
|
protocol.IProtocolReader
|
|
// 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
|
|
func CreateEraseFileRule(cmd string, pattern string) *EraseFileRule {
|
|
return &EraseFileRule{
|
|
Cmd: cmd,
|
|
matcher: protocol.CreateRegexMatcher(pattern),
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|