This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Provide a Common API for Validating/Sanitizing a File Name | ||
---|---|---|---|
Product: | platform | Reporter: | tomwheeler <tomwheeler> |
Component: | Filesystems | Assignee: | tomwheeler <tomwheeler> |
Status: | NEW --- | ||
Severity: | normal | CC: | err |
Priority: | P3 | ||
Version: | -S1S- | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 130554 |
Description
tomwheeler
2011-09-08 17:19:13 UTC
This Wikipedia page lists validity rules for different systems: http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words And, for MS Windows, I guess this may be the definitive source: http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx Can you donate a patch? Yes, I think I should be able to implement it though it will probably be a week or two till I have time. I am reassigning the issue to me. Suggest considering ways to override which platform to be compatible with. For example, if default behavior is validate for platform you are running on then an option, like a system property, that filename is valid on other systems and/or all systems. A method signature that takes a platform, as an enum, as an option (with a pseudo ALL platform) might be handy. I was thinking the same thing, Ernie. That would be more flexible and allow someone to handle cases in which they're developing on one platform but will deploy to another. That would be especially helpful for things like EJB or Web application support, since people commonly develop on MS Windows but deploy to UNIX. The only problem is that, to avoid duplication, we'd probably want to use the Utilities.OS_* int constants. Ideally we could replace those with enum, but it would break backwards compatibility. I hate writing methods that take special int values, but can't think of a way offhand to use an enum without either duplicating existing code or breaking compatibility. One other question is whether we'd need to support any non-UNIX, non-Windows platforms (e.g. VMS or OS/400). NetBeans system requirements don't show that these are supported any more: http://netbeans.org/community/releases/70/relnotes.html#system_requirements but maybe people still support them for NB Platform applications. To avoid breaking those, maybe the default behavior should be to return true for isValid and to return the original string for sanitizeFileName (and maybe log a warning) for an unrecognized platform. > use the Utilities.OS_* int constants. Ideally we could replace those
> with enum, but it would break backwards compatibility.
I know, I thought I'd put it out there anyway. I really like the self documenting aspect of enums (getting a list for combo box) and ...
One approach is to embed the magic number in the enum and have something like
validate(int platform) // uses OS_* int constants
validate(Platform platform) { return validate(platform.MAGIC_NUMBER); }
of course, getting agreement to define such an global enum for general use might not get much traction.
|