Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-02

Mode field for TSearchRec under UNIX

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michalis Kamburelis

Hi

Kylix adds field "Mode" to TSearchRec type under Linux. This field comes directly from UNIX stat structure (st_mode field). It is useful when you already have TSearchRec describing some file and you want to check the exact type of that file, e.g. "is it a symbolic link ? is it a device ?". It would be silly to call lstat with full filename, when all needed information was already available when constructing TSearchRec for this file.

I am not exactly a Kylix enthusiast but this "Mode" field is something that I consider useful. I guess that you will agree with this since you already added OS-specific fields to TSearchRec for Windows and Netware.

So I made a small patches to "rtl/objpas/sysutils/filutilh.inc" and "rtl/unix/sysutils.pp" to implement this. Well, that wasn't much work; all information was already available. I'm attaching those patches as "filutilh.inc.patch" and "sysutils.pp.patch". I'm also attaching very short demo program, "mode_field_demo.pas", to show that it really works.

Note: it would be more elegant to wrap "Mode" field inside something like "FindData: TUNIXFindData". This would break Kylix compatibility, but I don't know is there a real need to be compatible with Kylix. Personally, I want something like "Mode" field to be included in TSearchRec not because of Kylix compatiblity but because it's just useful.

BTW: Are you going to apply my Libc fixes (from letter "A few fixes for Libc unit") ? If you want I can provide a simple test program (to show that those fixes are really needed and that they are really fixing the problems) and/or ready-to-apply patches.

Regards,
Michalis

Reply by email