[fpc-pascal] Function for checking correct file name

Sven Barth pascaldragon at googlemail.com
Sat Sep 15 11:54:12 CEST 2012

On 15.09.2012 11:34, Vinzent Höfler wrote:
> On Sat, 15 Sep 2012 11:20:53 +0200, Sven Barth
> <pascaldragon at googlemail.com> wrote:
>> On 14.09.2012 17:44, Graeme Geldenhuys wrote:
>>> On 14/09/12 13:48, Krzysztof wrote:
>>>> I just quicky googled not allowed characters and wrote this simple
>>>> function:
>>> Also in Windows (as far as I know), file names my not be longer than 255
>>> characters. So you will have to check the length of AFilename parameter
>>> too.
>> It depends. If you use normal "C:\bla\bla" notation you are right, but
>> if you access the NT namespace (which you can do from within the
>> WinAPI) you can use paths with up to 32767 characters. You need to use
>> this notation though: "\\?\C:\bla\bla" (in this case you MUST use "\"
>> though as "/" is not converted here).
> Careful. There's a difference between file/component length and path
> length.
>> For more information see here:
>> http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath
> |This type of path is composed of components separated by backslashes,
> |each up to the value returned in the lpMaximumComponentLength parameter
> |of the GetVolumeInformation function (this value is commonly 255
> characters).
> So, although the path may be up to 32767 characters in length, each
> component
> of the path can no longer than 255 characters. This includes the file name.

Right... but 255 characters for a filename is already rather much as 
well when I compare this with the amount of text I can squash into a SMS ;)


More information about the fpc-pascal mailing list