On 3/1/06, Ron Grabowski (JIRA) <[EMAIL PROTECTED]> wrote:
>     [ 
> http://issues.apache.org/jira/browse/LOG4NET-66?page=comments#action_12368446 
> ]
>
> Ron Grabowski commented on LOG4NET-66:
> --------------------------------------
>
> I don't like the idea of using a regular expression to match filenames:

It is a bit heavy handed anyway.

I've removed the regular expression related code and attached an
updated diff to the JIRA issue.

>  "^" + Path.GetFileNameWithoutExtension(baseFileName) + "(\\.[0-9]*)?\\" + 
> Path.GetExtension(baseFileName) + "$"
>
> Wouldn't these filenames cause the regular expression to misbehave (square 
> brackets, parenthesis, and the period have special meaning in regular 
> expressions)?

Regular expressions allow you to match against source text including
its special characters by prefixing the special character in the
pattern with a back-slash.

>
>  log[2.0].txt
>  log[2.0].txt.1
>  log[2.0].txt.2
>  log(1.1).txt
>  log(1.1).txt.1
>  log(1.1).txt.2
>  log(1.1).txt.3
>

Filenames with numeric extensions should never be generated when
preserveFileNameExtension is used. Maybe it needs warning text (like
that for staticFileName) highlighting that strange things need to
happen if you don't clear the directory first.

> I suppose writing another helper method would solve the problem:
>
>  RegexEncode(Path.GetFileNameWithoutExtension(baseFileName))
>
> Is there a way to use DirectoryInfo's GetFiles style searching (DOS 
> wildcards) to achieve the same result?

Not that I've thought of.

What would have been better is to explicitly specify the extension to
be used and to remove the extension from the base filename. This would
probably fit in somewhat better with the original (non-extension
preserving code) and might even reduce overhead.

--
Mike Blake-Knox

Reply via email to