[Lazarus] How to create a directory from a path string? (cross-platform needed).

Sven Barth pascaldragon at googlemail.com
Fri Mar 18 11:30:49 CET 2011


Am 18.03.2011 10:53, schrieb Marco van de Voort:
> On Wed, Mar 16, 2011 at 09:39:38AM +0100, Sven Barth wrote:
>>> explain.
>>>
>>> An example, please?
>>
>> While the others already sent you the correct solution
>> ("ForceDirectories") I just wanted to note, that FPC abstracts all those
>> file and directory related functions for you. There are for example the
>> very low level functions mkdir and rmdir that are part of the System unit.
>>
>> See here: http://www.freepascal.org/docs-html/rtl/system/mkdir.html
>>
>> Then there are the functions defined in SysUtils like CreateDir,
>> ForceDirectories and RemoveDir.
>
> Note that for some cases, security aware programs (CGI, daemons), you have
> to be a bit more careful. A known dangerous case is stuff like
> forcedirectories on directory hierarchies where you don't have read
> permissions (but you do have "x" permissions) on all levels.
>

Outch... That could indeed be dangerous.

>> And recent Delphi versions also include a higher level by introducing
>> advanced record types that handle all this:
>> http://docwiki.embarcadero.com/VCL/en/IOUtils.TDirectory
>
> Fashion, not function. .NET has everything organized in static classes, and
> embacadero wants to look more modern.
>

They also want the language to look more like .NET (e.g. the attributes 
syntax). *sigh* (or in other words: they take the cheap way by reusing 
the Delphi.NET parser...)

> I wouldn't call this higher level. It is the same level just in OOP style.

Ok... fine as well. :)

Regards,
Sven




More information about the Lazarus mailing list