[fpc-devel]Mode field for TSearchRec under UNIX

Michalis Kamburelis michalis at camelot.homedns.org
Tue Feb 24 19:51:24 CET 2004


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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: filutilh.inc.patch
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20040224/dc5d0aca/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sysutils.pp.patch
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20040224/dc5d0aca/attachment-0001.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mode_field_demo.pas
Type: text/x-pascal
Size: 310 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20040224/dc5d0aca/attachment.pas>


More information about the fpc-devel mailing list