This exception is only raised if the Dir parameter is empty which is essentially an invalid argument for the function, after all it makes no sense to ensure that no path exists. Delphi behaves the same here, so nothing will be changed there.
mkdir(''); doesn't raise an exception.
ForceDirectories is not an equivalent to MkDir as that requires the parent directories to already exist.
I have doubts ordinary programmers enclose forcedirectories in try...except/finally blocks. It's counterintuitive.
Programmers will also very likely not pass empty strings to ForceDirectories which is the only case where that function raises an exception.
SetCurrentDir('/tmp/');ForceDirectories('subdir');
The above line creates a subdirectory in an existing '/tmp/' directory, same as
chdir('/tmp/');mkdir('subdir');//or
SetCurrentDir('/tmp/');CreateDir('subdir');
So, same as
mkdir and
CreateDir,
ForceDirectories supports relative paths, too.
After a
chdir/SetCurrentDir to an existing directory,
CreateDir('') always returns true while
ForceDirectories('') always raises an exception. Both
CreateDir and
ForceDirectories are in the same rtl/objpas/sysutils/disk.inc file. I would expect
ForceDirectories('') to return the same boolean result as
CreateDir(''), or both of them to raise the same SCannotCreateEmptyDir exception.