[fpc-pascal] Function for checking correct file name
Mattias Gaertner
nc-gaertnma at netcologne.de
Fri Sep 14 15:43:58 CEST 2012
Mark Morgan Lloyd <markMLl.fpc-pascal at telemetry.co.uk> hat am 14. September 2012
um 15:18 geschrieben:
> Krzysztof wrote:
> > I just quicky googled not allowed characters and wrote this simple function:
> >
> > function IsValidFilename(const AFilename: String): Boolean;
> > var
> > c: set of Char = ['<','>',':','"','/','\','|','?','*', '%', '.'];
> > i: Integer;
> > begin
> > Result := True;
> > for i:=1 to Length(AFilename) do
> > if AFilename[i] in c then
> > Exit(False);
> > end;
> >
> > So, problem solved. Thanks and regards
>
> But several of those are fine in filenames- just inadvisable since they
> need special quoting/escaping to get past the shell. As does ' ' which
> isn't in your list :-)
And it does not check for #0..#31, #127.
Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120914/e2c2a0e1/attachment.html>
More information about the fpc-pascal
mailing list