procedure TmainFrm.filesBoxEdited(Sender:TObject; Node:TTreeNode; var S:String);
var
f: Tfile;
begin
f:=node.data;
if f.name = s then exit;
if f.isFile() and not validFilename(s)
or (s = '')
or (pos('/',s) > 0)
then
begin
s:=node.text;
msgDlg('Invalid filename', MB_ICONERROR);
exit;
end;
if existsNodeWithName(s, node.parent)
and (msgDlg(MSG_SAME_NAME, MB_ICONWARNING+MB_YESNO) <> IDYES) then
begin
s:=node.text;
exit;
end;
f.name:=s;
VFSmodified:=TRUE;
updateUrlBox();
end;
1) Is '(pos('/',s) > 0)' necessary? '/' is already an invalid character.
2) An invalid filename is detected but only if it is a file. But under Windows,
Files and Folders are considered as being a part of the
same family, the test ' f.isfile' is too.
That incites me to subject a question to everyone:
Under Windows, it is possible to look for files in a some arborescence 'Find files or foders/ F3'.
you can user meta characters as * and ? . You can combinate a multi search by separate items by a ';'
*.pas;*.dcu;*.ini
In a folder,you can create 3 files with the name 'test;document.xxx' wher xxx is different every time ( txt , ini , log .
do a search on this folder with the exact name 'test;document.txt', there is no meta characters, However the result is not only one file named 'test;document.txt', but all files which contains 'test' or 'document.txt'.
Morality, it is necessary to banish also the character ';' in the name of files.
ILLEGAL_FILE_CHARS = [#0..#31,'/','\',':','?','*','"','<','>','|',';'];[/quote]
If somebody wants that I give him a good reason, it is simple: HFS uses two caracters of separation (see in hfs.ini) and they are '|' and ';'
It maybe has no negative effects on the VFS but the caution is rigorous.