Directory or link? lazarus / 1-Linux ---------------------------------------------------------------------- bonmario · 2008-01-24 18:25 Hi, i found this code that must say if a path is a real directory or a link: Code: [Select]function IsRealDirectory(FilePath, Value: String): Boolean;   var     info: stat;   begin     Result := false;     if not ((Value='.') or (Value='..') or (Value='')) then     begin       fplstat(FilePath+Value,@info);       if info.nlink<>1 then Result := true;     end;   end; but this code have a problem: used on a drive NTFS, return always "false". Someone can say me how determine if a path is a directory or a link? Thanks, Mario ---------------------------------------------------------------------- Phil · 2008-01-24 19:39 Quote from: "bonmario"Hi, i found this code that must say if a path is a real directory or a link: Code: [Select]function IsRealDirectory(FilePath, Value: String): Boolean;   var     info: stat;   begin     Result := false;     if not ((Value='.') or (Value='..') or (Value='')) then     begin       fplstat(FilePath+Value,@info);       if info.nlink<>1 then Result := true;     end;   end; but this code have a problem: used on a drive NTFS, return always "false". Someone can say me how determine if a path is a directory or a link? Thanks, Mario If you use FpLStat on a real directory, shouldn't it fail since it's not a link? That is, if FpLStat fails (non-zero result), your function should return True; if it succeeds (0 result), return False. Maybe I'm misreading rtl.pdf on FpLStat and I don't use Linux to test this idea. Thanks. -Phil ---------------------------------------------------------------------- bonmario · 2008-01-24 20:27 Quote from: "Phil"If you use FpLStat on a real directory, shouldn't it fail since it's not a link? That is, if FpLStat fails (non-zero result), your function should return True; if it succeeds (0 result), return False. Maybe I'm misreading rtl.pdf on FpLStat and I don't use Linux to test this idea. Thanks. -Phil I've tried, but the result of FpLstat is 0 both with a real directory and with a link ---------------------------------------------------------------------- Bart · 2008-01-25 10:48 You are running this from Linux I guess? On NTFS symlinks Windows also reports symlinks as being a real directory, that is FindFirtsFile does. It will return faDirectory and FILE_ATTRIBUTE_REPARSEPOINT in its attribute. All this is (as usual) rather badly documented (and badly implemented too. Try to delet a NTFS symlink from within the Explorer, and only God knows what happens then, or even later). What does fpS_ISLNK() return on the stat info that FplStat returns? Bart ---------------------------------------------------------------------- bonmario · 2008-01-26 10:24 Quote from: "Bart" What does fpS_ISLNK() return on the stat info that FplStat returns? Bart Ubuntu 7.10, with GTK 2 Thanks, i have solved with fpS_ISLNK() ---------------------------------------------------------------------- Bart · 2008-01-29 16:52 Sure, linux does a better job on NTFS then Windows itself. Surprising? Bart