Lazarus

Programming => General => Topic started by: MarkMLl on January 24, 2021, 01:10:49 pm

Title: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 01:10:49 pm
On Linux x86_64, there appears to have been a change in FileExists() between FPC 3.0.4 and 3.2.0. This has broken some delicate code (resulting in indelicate language after a long debugging session) which walked the /sys/devices tree trying to determine properties of a serial port... I've not found any way other than brute force to determine things like hardware and driver name since different drivers (kernel modules) store this information differently.

This is the content of the relevant directory:


/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/ttyUSB0# ls -l
total 0
lrwxrwxrwx 1 root root    0 Jan 24 10:23 driver -> ../../../../../../../bus/usb-serial/drivers/cp210x
-r--r--r-- 1 root root 4096 Jan 24 10:23 port_number
drwxr-xr-x 2 root root    0 Jan 24 10:24 power
lrwxrwxrwx 1 root root    0 Jan 24 10:23 subsystem -> ../../../../../../../bus/usb-serial
drwxr-xr-x 3 root root    0 Jan 24 10:23 tty
-rw-r--r-- 1 root root 4096 Jan 24 10:23 uevent


This is the relevant code fragment:

Code: Pascal  [Select][+][-]
  1. DebugWriteF('Test existence "%s" "%s" / "%s"\n', [dir, candidate, content]);
  2. if FileExists(dir + candidate + '/' + content) then begin
  3.   DebugWriteF('Test predicate "%s" "%s" "%s" "%s"\n', [dir, candidate, content, extra]);
  4.   if wtp2(dir, candidate, content, extra, hint) then
  5.     exit(dir + candidate + '/')
  6. end
  7.  

Code compiled with 3.0.4 gives me this output:


Testing against driver name usb-serial/drivers/cp210x
Test existence "/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/" "ttyUSB0" / "driver"
Test predicate "/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/" "ttyUSB0" "driver" "usb-serial/drivers/cp210x"
...


Code compiled with 3.2.0 gives me this output:


Testing against driver name usb-serial/drivers/cp210x
Test existence "/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/" "ttyUSB0" / "driver"
...


Before I dig in again myself, what is FileExists() objecting to here: the fact that it's looking at a symlink, the fact that it's looking at a symlinked directory, or the fact that it's looking at a directory?

Is this an intentional change, i.e. which will persist in later versions of the compiler, or a regression which I can avoid by telling people not to use that specific version of compiler?

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: Kays on January 24, 2021, 02:11:17 pm
[…] Is this an intentional change […]? […]
Yes, it’s intentional (https://wiki.freepascal.org/User_Changes_3.2.0#FileExists_on_Unix-based_systems).
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 02:14:07 pm
[…] Is this an intentional change […]? […]
Yes, it’s intentional (https://wiki.freepascal.org/User_Changes_3.2.0#FileExists_on_Unix-based_systems).

Thanks for that. So it's the directory check, not that it's going via a symlink.

The code finds and reads a Mastech MS2115B multimeter, and I'll be reusing it to read a pulse oximeter when the hardware arrives since the serial chip and overall requirement is the same. https://github.com/MarkMLl/Mastech_ms2115b

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: jamie on January 24, 2021, 02:49:39 pm
I think someone made a mistake in their logic of thinking..

from day one of my experience of coding in OSes, everything is a file, even in DOS the director "File" had it's own extension using the the "." or ".." extensions. So with that it was easy to copy a whole directory because it was treated as a single file..


 Maybe they may want to revaluate their decision on this ?
Title: Re: FileExists() behaviour changed on Linux
Post by: winni on January 24, 2021, 03:01:49 pm
I think someone made a mistake in their logic of thinking..

from day one of my experience of coding in OSes, everything is a file, even in DOS the director "File" had it's own extension using the the "." or ".." extensions. So with that it was easy to copy a whole directory because it was treated as a single file..


 Maybe they may want to revaluate their decision on this ?

Yes that is true

It is the old Unix idea "Everything is a file"

So a symlink is nothing but a file pointing to another file.

Winni
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 03:10:59 pm
I think someone made a mistake in their logic of thinking..

from day one of my experience of coding in OSes, everything is a file, even in DOS the director "File" had it's own extension using the the "." or ".." extensions. So with that it was easy to copy a whole directory because it was treated as a single file..

 Maybe they may want to revaluate their decision on this ?

From my POV I'm glad to know the status of things and am changing my directory walking code to make both calls where necessary in order to emulate the original behaviour since I'm not confident that switching to DirectoryExists() would always be correct. However I would make two comments.

The first is that in my case there will be a performance hit on what was already a fairly slow brute-force operation since if FileExists() fails I'm now making a second call to DirectoryExists(). Since this is Linux-specific I think I could probably improve things by making an fpStat() call instead.

The second is that IMO (and with all respect to Jamie), "everything is a file" is a mantra that is invoked far too often. "Everything appears in the filesystem namespace" is one thing, but increasingly there are physical and socket-like devices which quite simply don't map well onto the file API... you can open them by name and everything else is a private API via ioctl calls. And then there's e.g. Linux network devices which don't even appear in the filesystem namespace.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 03:18:17 pm
So a symlink is nothing but a file pointing to another file.

Hmm. A symlink is an instance of an object which reimplements open() etc. via redirection.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: jamie on January 24, 2021, 03:26:30 pm
Well I've always liked the methodology of LINUX/UNIX of everything is a file because with devices , the last time I did serial on Linux, you had the device which acted as a file (directory tree Device NAME) and then sub files which were a data channel file and the control file and from that you could simply open two files within the directory (Device name) one being the control and one being the data file. Read or write...

 Like I said its been years since I've done this but that is basically how I did it, get the device name which acted like file or Directory name and then you could in theory enumerate the sub files of that device to see what was available.

some devices maybe read only like a Mouse for example but in any case that device folder/Director held attributes about it..

 By doing work this way you never had to concern yourself with machine design logic from the application level where as with DOS and windows it's still a need to know these things.
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 03:31:53 pm
Somebody needs to fix the documentation

https://www.freepascal.org/docs-html/current/rtl/sysutils/fileexists.html

"On Unixes, passing a directory name will result in True. The rationale is that on UNIX, a directory is a file as well."

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 03:34:13 pm
Well I've always liked the methodology of LINUX/UNIX of everything is a file because with devices , the last time I did serial on Linux, you had the device which acted as a file (directory tree Device NAME) and then sub files which were a data channel file and the control file and from that you could simply open two files within the directory (Device name) one being the control and one being the data file. Read or write...

I've definitely never seen anything like that on Linux or for that matter Solaris, although it could obviously be done like that on e.g. smart multiport cards.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: jamie on January 24, 2021, 07:54:43 pm
I have serial port code and sound card code here on an redhat machine that did exactly that for those services, They open multiple files against the device for data access and control

 I may have some source code kicking around that I could post, I need to find the archive I back them up on.
Title: Re: FileExists() behaviour changed on Linux
Post by: Bart on January 24, 2021, 08:20:55 pm
The reason for the change is consistency across platforms.
The behaviour on Windows is Delphi compatible.
It also avoids code like:
Code: Pascal  [Select][+][-]
  1.   if FileExists(Fn) and not DirectoryExists(Fn) then
  2.     DoSomeThingWithThe File(Fn);
Constructs like that appeared in LCL code IIRC.

Bart
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 09:29:33 pm
The reason for the change is consistency across platforms.
The behaviour on Windows is Delphi compatible.

IMO, a gross change which flies in the face of documented behaviour would have merited a parameter change to make sure that people were aware of it, e.g making the 2nd parameter mandatory and using it to specify not just whether a symlink should be followed but what would match.

How long has this change been planned? Why aren't the developers using the deprecated/experimental qualifiers or introducing changepending/changedrecently ones?

Yes, I appreciate that this was in the release notes and that I should have checked earlier. But what's going to be changed next: clBlack swapped with clWhite?

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: jamie on January 24, 2021, 09:40:50 pm
how about a "PathExist" function...

at least that follows some other language thinking..

I will stick to FileAttr I guess for a single function for now..
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 09:54:38 pm
Problem there is that "path" will get confused with the directory portion (i.e. with name.extension trimmed). I was looking at FileAttr() earlier, and it looks rather "DOSsy": in my case I do a fair amount of checking of unix-domain sockets etc., and in that case FileAttr()'s behaviour should be undefined.

OI! DEVS! Are you going to change things so that FileExists() doesn't match a unix FIFO or unix-domain socket, in order to conform to Delphi's behaviour? After all, Delphi doesn't run on unix so can't be expected to match them, so it would be entirely reasonable to follow things through to their logical conclusion :-/

Look, I'm sorry if I sound negative about all this. But this was a BREAKING CHANGE and it was my code that got broken.

SHOULD. NOT. HAVE. HAPPENED.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: Bart on January 24, 2021, 09:56:20 pm
I will stick to FileAttr I guess for a single function for now..
Try FindFirst('C:\', faDirectory, SR) to see if 'C:\' exists and get a nice surprise.
Some code in fpc uses that to detect if it is a directory and fails.

Root folders on NT systems have the system and hidden bit set...

Bart
Title: Re: FileExists() behaviour changed on Linux
Post by: trev on January 24, 2021, 10:36:54 pm
This statement (https://wiki.lazarus.freepascal.org/User_Changes_3.2.0#FileExists_on_Unix-based_systems) is just WRONG. On UNIX systems a directory IS a file.

Also, the FPC "RenameFile" function also renames directories, but now the FileExists function no longer works for directories.

This is madness.
Title: Re: FileExists() behaviour changed on Linux
Post by: BeniBela on January 24, 2021, 11:06:06 pm
I just noticed that this breaks my code as well yesterday



How long has this change been planned? Why aren't the developers using the deprecated/experimental qualifiers or introducing changepending/changedrecently ones?


I do not think there was any planing involved

https://bugs.freepascal.org/view.php?id=8900

 https://bugs.freepascal.org/view.php?id=16938

 https://bugs.freepascal.org/view.php?id=32362
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 11:06:42 pm
This statement (https://wiki.lazarus.freepascal.org/User_Changes_3.2.0#FileExists_on_Unix-based_systems) is just WRONG. On UNIX systems a directory IS a file.

As is a symlink. This is a can of worms :-(

Quote
Also, the FPC "RenameFile" function also renames directories, but now the FileExists function no longer works for directories.

Oh Lord :-(

OK, I've got a suggestion. "File" in these functions shouldn't be interpreted as "this is a file containing arbitrary data", but as "this is something in the filesystem namespace which is subject to the unix file API".

The change has happened, and there is probably a fair number of "on the ball" users who have moved onto 3.2.0, in most cases probably not realising there is an issue which might bite them when they recompile their code using it. Sooner rather than later we need a 3.2.2 which either reverts this or (and I think this would be my preference) changes FileExists() to make the second parameter mandatory and used to represent what it will match: that will alert anybody who is recompiling their code regularly to the fact that there are problems in this area.

And obviously FindFirst() etc. need to be reviewed for compliance with the spirit of POSIX or whatever MS claims to conform to.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: jamie on January 24, 2021, 11:15:28 pm
I just was playing around with something here..

Code: Pascal  [Select][+][-]
  1. Function PathExists(Name :String):Boolean; inline;
  2.  begin
  3.    Result := FileGetAttr(Name) >=0;
  4. End;
  5.  

This seems to work well on windows... I also believe you can use unc file names within this...

The function returns -1 if there is some error, Meaning if it can't read it then it must not exist!

This was hand typed so forget any errors that maybe in this tag..
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 24, 2021, 11:32:21 pm
> Result := FileGetAttr(Name) >=0;

But since FileGetAttr() appears to be defined in terms of a DOS-style filesystem, is it really applicable when considering a unix or NTFS filesystem which has different attributes?

The same applies to fpStat() and in particular to the st_mode field that it returns, but I think it would be easier to map Windows attributes onto POSIX than to shoehorn unix/POSIX attributes into DOS-style function results :-/

The bottom line is that most OSes at least play lipservice to POSIX,  so if anybody's out of line here it's Delphi which doesn't go out of its way to consider non-Windows targets. So WTF are we still going out of our way to conform to Delphi's broken ideas?

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: dsiders on January 25, 2021, 12:41:34 am
So WTF are we still going out of our way to conform to Delphi's broken ideas?

Because the faithful do not eat their sacred cows... even during a famine. ;)
Title: Re: FileExists() behavior changed on Linux
Post by: Kays on January 25, 2021, 01:02:09 am
[…] I'm […] changing my directory walking code to make both calls where necessary in order to emulate the original behaviour since I'm not confident that switching to DirectoryExists() would always be correct […]
Oh dear. You’re changing it by hand? I’d quickly drop in some of my central unit or include file something like:
Code: Pascal  [Select][+][-]
  1. {$if FPC_fullVersion >= 030200}// fileExist `false` on directories
  2. function fileExists(const s: string; const r: Boolean = true): Boolean;
  3. begin
  4.         {$push}
  5.         {$boolEval off} // until `or_else` becomes available
  6.         fileExists := sysUtils.fileExists(s, r) or
  7.                 sysUtils.directoryExists(s, r);
  8.         {$pop}
  9. end;
  10. {$endIf}
Boom! No need change your code. Just verify you never used the FQI somewhere else
Code: Bash  [Select][+][-]
  1. egrep -Ri 'sysutils[[:blank:]]*.[[:blank:]]*fileexists' ./*

[…] if FileExists() fails I'm now making a second call to DirectoryExists(). Since this is Linux-specific I think I could probably improve things by making an fpStat() call instead.
Walking the SysFS directory tree (https://en.wikipedia.org/wiki/Sysfs) already by itself is a Linux-specific thing. Ergo, there is no benefit in attempting to keep your code cross-platform. Examining an strace(1) of fileExists I see every successful access(2) (https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html) is (now) followed by a stat(2) (https://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html) just to filter out any matching directories (“false positives”). In fact, fpAccess(…, F_OK) (https://www.freepascal.org/docs-html/rtl/baseunix/fpaccess.html) would be sufficient for you.

Somebody needs to fix the documentation […]
It’s already documented since revision 1730 (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/sysutils.xml?root=docs&r1=1690&r2=1730).

[…] So a symlink is nothing but a file pointing to another file. […]
A symbolic link is a shortcut for typing out a path. A symbolic link may point to non-existent files and can point across file system boundaries. (For the purposes of this statement “file” also includes directories.)

The reason for the change is consistency across platforms.
The behaviour on Windows is Delphi compatible. […]
Here we go again. Delphi-compatibility is like the holy grail. To quote trev here:
[…] This is madness.
I actually think the change is warranted though, but for the reason of having consistent behavior across all platforms. If Windoze doesn’t deem directories as files, then fileExists should fail on all platforms; there’s directoryExists just for directories.
Title: Re: FileExists() behaviour changed on Linux
Post by: lucamar on January 25, 2021, 01:23:18 am
So WTF are we still going out of our way to conform to Delphi's broken ideas?

For the same old reason: there is still a lot more code intended for Delphi that might have to behave "the right way" in FreePascal than viceversa. We might like it or not but Delphi compatibility is still important.

IMHO, of course. :-\
Title: Re: FileExists() behavior changed on Linux
Post by: MarkMLl on January 25, 2021, 10:20:05 am
Oh dear. You’re changing it by hand? I’d quickly drop in some of my central unit or include file something like:

Inserting a function like the one you suggested was no big deal. Unfortunately I don't understand my code well enough to be 100% confident of where I definitely needed the old behaviour or where the new one would be better, so I've ended up with perhaps a dozen edits over three projects.

Quote
Walking the SysFS directory tree (https://en.wikipedia.org/wiki/Sysfs) already by itself is a Linux-specific thing. Ergo, there is no benefit in attempting to keep your code cross-platform.

It's a general-purpose function which potentially could be used for other things. As such it's worth keeping it portable.

Quote
It’s already documented since revision 1730 (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/sysutils.xml?root=docs&r1=1690&r2=1730).

OH NO IT'S EFFING NOT!!!

The live documentation for FPC 3.2.0 is at https://www.freepascal.org/docs-html/current/rtl/sysutils/fileexists.html and it says "On Unixes, passing a directory name will result in True. The rationale is that on UNIX, a directory is a file as well."

Apropos the remainder... my beef is not so much with the change in behaviour, but the fact that this is an undocumented breaking change which has been slipped in with no attempt at getting the compiler to warn the user that his program might no longer work as expected.

As Pascal users we boast that the language's type checking etc. is better- or at least longer-established- than that of the competition, and that robust design and careful implementation helps catch problems early and makes programs more reliable.

But the reputation for caution and consistency that the developers have cultivated over the last 20 years risks being swept away by a single ill-considered change.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: Thaddy on January 25, 2021, 10:24:33 am
The documentation is adapted in 3.3.1 and possibly 3.2.1 as back port. Both are FF'ng (op.cit) not releases. The online docs reflect the latest release which is 3.2.0.
You can build the latest docs yourself, though.
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 25, 2021, 10:44:25 am
The documentation is adapted in 3.3.1 and possibly 3.2.1 as back port. Both are FF'ng (op.cit) not releases. The online docs reflect the latest release which is 3.2.0.
You can build the latest docs yourself, though.

Let's try again. If we point a user at the download page https://www.freepascal.org/download.html it explicitly says "The latest release is 3.2.0" and offers him e.g. ftp://ftp.hu.freepascal.org/pub/fpc/dist/3.2.0/x86_64-linux/fpc-3.2.0-x86_64-linux.tar.

If he wants to read the documentation for FileExists() he will go to https://www.freepascal.org/docs-html/current/rtl/sysutils/fileexists.html

That is the public documentation for the FileExists() function being shipped in 3.2.0.

In words of one sound each, IT IS WRONG AND NEEDS TO BE FIXED.

Otherwise the only thing I can conclude is that the core developers have absolutely no interest in anybody other than themselves using the compiler.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: dbannon on January 25, 2021, 10:58:58 am
Putting aside, momentarily, the process for this change, the change itself, IMHO, makes sense.  As a long time Unix/Linux user, yes I am aware that everything in Unix is a file, thats not just a characteristic, its a key feature. But only at a Operating System level. I know for example, you can open a directory with vi, but I have no idea what you happen if I wrote changes to it ....

For an application, a file is different to a directory, an application does not care how a directory is treated by the OS, it cares that a directory can contain files, it cannot 'open' a directory to read data, it cannot find multiple files in a file.

If, at an application level, I want to know if a directory exists, it seems sensible to me to use DirectoryExists(). Similarly, for a file, FileExists().  I care not that its Delphi compatible, its sensible in its own right. At an application level.

Davo
Title: Re: FileExists() behaviour changed on Linux
Post by: Thaddy on January 25, 2021, 11:54:36 am
When one uses features of a non-release, you will have to build the docs. As simple as that. If you can build the non-releases, like fixes and trunk, you should also be able to build the docs as well. >:D The above is a non-discussion imnsho.

Note it would be a nice feature for fpcdeluxe to build the docs as well, but e.g. on Windows this is not trivial in my experience. Linux, no problems.
Title: Re: FileExists() behaviour changed on Linux
Post by: MarkMLl on January 25, 2021, 11:59:12 am
When one uses features of a non-release, you will have to build the docs. As simple as that. If you can build the non-releases, like fixes and trunk, you should also be able to build the docs as well. >:D The above is a non-discussion imnsho.

Thaddy. This change is in the released 3.2.0. It should be documented.

MarkMLl
Title: Re: FileExists() behaviour changed on Linux
Post by: Kays on January 25, 2021, 12:53:47 pm
[…] It should be documented.
Oh, looooooosen up. The documentation is sometimes buggy. Shit happens. Big deal!
Title: Re: FileExists() behaviour changed on Linux
Post by: Thaddy on January 25, 2021, 01:01:30 pm
No, it is not buggy - in this case!. Documentation on-line or official distribution belongs to a release, in this case 3.2.0.
If you want up-to-date docs, you have to build them...
That does not mean the docs can not contain bugs, but not in this case. Here is it is a mismatch between versions.
There is a reason for that: many use the pre-built installers from the official repo. You can not go and document features or fixes that are not in that repo. Period.
Title: Re: FileExists() behaviour changed on Linux
Post by: lucamar on January 25, 2021, 01:21:54 pm
Thaddy, the problem is that the change is in the 3.2.0 release but the documentation doesn't reflect it. It's a documentation bug.

Though it's advertised in the release notes in the wiki which, if I may make so bold, one should read  always before installing a new one.
Title: Re: FileExists() behavior changed on Linux
Post by: Kays on January 25, 2021, 01:23:53 pm
No, it is not buggy - in this case!.
Yes, it is. revision 1730 (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/sysutils.xml?root=docs&r1=1690&r2=1730) was committed on August 2.

The FPC 3.2.0 with a modified fileExists implementation (https://wiki.freepascal.org/User_Changes_3.2.0#FileExists_on_Unix-based_systems) was released on June 19. The corrected sysutils.xml did not make it in time. Everything that’s been packaged/generated prior August 2 contains a wrong behavior description. This is how time works, there is no arguing.

I do get MarkMLl’s point: I dare say no ordinary FPC user is regularly checking out and regenerating the latest documentation on their own. I primarily just take the pre-packaged documentation (or what’s on the website (https://freepascal.org/docs.var)), too. There is no point in referring me and others to “But in trunk it’s right. Since August 2.” Only developers look there.
Title: Re: FileExists() behavior changed on Linux
Post by: Thaddy on January 25, 2021, 01:28:29 pm
Only developers look there.
Nope. I and many others do too... that's the point... published docs are strictly tied to releases. Also fixes in docs are tied to fixes or trunk.
Consider docs as "in print" and you know what I mean. Subsequent editions (like 3.2.1) contain the erratum's. But you have to create those editions yourself as it stands. Hence I suggested that maybe fpcdeluxe can also build docs conforming to what is checked out as compiler version.
(Although that is torturing the fpcdeluxe maintainer  :'( )
Title: Re: FileExists() behavior changed on Linux
Post by: PascalDragon on January 25, 2021, 01:50:38 pm
I do get MarkMLl’s point: I dare say no ordinary FPC user is regularly checking out and regenerating the latest documentation on their own. I primarily just take the pre-packaged documentation (or what’s on the website (https://freepascal.org/docs.var)), too. There is no point in referring me and others to “But in trunk it’s right. Since August 2.” Only developers look there.

Since a few weeks ago a daily snapshot (https://www.freepascal.org/daily/daily.html) of the documentation is generated so that users can check this more easily.
Title: Re: FileExists() behaviour changed on Linux
Post by: trev on January 25, 2021, 01:51:58 pm
I know for example, you can open a directory with vi, but I have no idea what you happen if I wrote changes to it ....

emacs .fltk shows:

Quote
/home/trev/.fltk/fltk.org:
  total used in directory 2 available 322.2 GiB
  drwx------  2 trev  wheel   3  3 Jun  2017 .
  drwx------  3 trev  wheel   3  3 Jun  2017 ..
  -rw-r--r--  1 trev  wheel  94 31 Jan  2019 fltk.prefs

Quote
For an application, a file is different to a directory, an application does not care how a directory is treated by the OS, it cares that a directory can contain files, it cannot 'open' a directory to read data, it cannot find multiple files in a file.

It can open a directory to read data - see above :)

Quote
If, at an application level, I want to know if a directory exists, it seems sensible to me to use DirectoryExists(). Similarly, for a file, FileExists().  I care not that its Delphi compatible, its sensible in its own right. At an application level.

And renamefile() renames files AND directories, nicely consistent not!
Title: Re: FileExists() behaviour changed on Linux
Post by: DonAlfredo on January 25, 2021, 02:18:46 pm
@Thaddy
It should .... but based on Lazarus version and not FPC ... but needs an update ... soon !
Code: Pascal  [Select][+][-]
  1.   HELPSOURCEURL : array [0..15,0..1] of string = (
  2.     ('0.9.28','/Old%20releases/Lazarus%200.9.28/fpc-lazarus-0.9.28-doc-chm.tar.bz2'),
  3.     ('0.9.30','/Old%20releases/Lazarus%200.9.30/fpc-lazarus-doc-chm-0.9.30.tar.bz2'),
  4.     ('0.9.30.4','/Old%20releases/Lazarus%200.9.30.4/fpc-lazarus-doc-chm-0.9.30.4.tar.bz2'),
  5.     ('1.0.0','/Old%20releases/Lazarus%201.0/fpc-lazarus-doc-chm-1.0.zip'),
  6.     ('1.0.12','/Lazarus%201.0.12/fpc-lazarus-doc-chm-1.0.12.zip'),
  7.     ('1.2','/Lazarus%201.2/fpc-lazarus-doc-chm-1.2.zip'),
  8.     ('1.4','/Lazarus%201.4/doc-chm_fpc2014_laz2015.zip'),
  9.     ('1.6','/Lazarus%201.6/doc-chm-fpc3.0.0-laz1.6.zip'),
  10.     ('1.6.4','/Lazarus%201.6.4/doc-chm-fpc3.0.2-laz1.6.zip'),
  11.     ('1.8','/Lazarus%201.8.0/doc-chm-fpc3.0.2-laz1.8.zip'),
  12.     ('1.8.2','/Lazarus%201.8.2/doc-chm-fpc3.0.2-laz1.8.zip'),
  13.     ('1.8.4','/Lazarus%201.8.4/doc-chm-fpc3.0.4-laz1.8.zip'),
  14.     ('2.0.0','/Lazarus%202.0.0/doc-chm-fpc3.0.4-laz2.0.zip'),
  15.     ('2.0.2','/Lazarus%202.0.2/doc-chm-fpc3.0.4-laz2.0.2.zip'),
  16.     ('2.0.4','/Lazarus%202.0.4/doc-chm-fpc3.0.4-laz2.0.4.zip'),
  17.     ('2.0.6','/Lazarus%202.0.6/doc-chm-fpc3.0.4-laz2.0.6.zip')
  18.   );
  19.  
Title: Re: FileExists() behavior changed on Linux
Post by: marcov on January 25, 2021, 02:41:16 pm
I do get MarkMLl’s point: I dare say no ordinary FPC user is regularly checking out and regenerating the latest documentation on their own. I primarily just take the pre-packaged documentation (or what’s on the website (https://freepascal.org/docs.var)), too. There is no point in referring me and others to “But in trunk it’s right. Since August 2.” Only developers look there.

If you would look in the documentation subgroup on this forum, you would find snapshots of december and january.
Title: Re: FileExists() behavior changed on Linux
Post by: Kays on January 26, 2021, 12:49:37 am
Only developers look there.
Nope. I and many others do too... that's the point... […]
I mean, I do, too, but only in cases like this one at hand: When the observed behavior differs from documented (as of at the point of the release) behavior.

I do not consult trunk documentation as my primary source of information to find out information for FPC 3.2.0. trunk documentation may contain per definition documentation that’s not relevant [new features] or even wrong for the latest production release [3.2.0].

Since a few weeks ago a daily snapshot (https://www.freepascal.org/daily/daily.html) of the documentation is generated so that users can check this more easily.
Awesome! But I got disappointed right away, that the RG doesn’t show properly rendered syntax diagrams. :(
Title: Re: FileExists() behavior changed on Linux
Post by: PascalDragon on January 26, 2021, 09:07:26 am
Since a few weeks ago a daily snapshot (https://www.freepascal.org/daily/daily.html) of the documentation is generated so that users can check this more easily.
Awesome! But I got disappointed right away, that the RG doesn’t show properly rendered syntax diagrams. :(

RG? Anyway: the point of the dailies is also that users can easier find bugs in the documentation process, so please reports things you notice (like this one).
Title: Re: FileExists() behavior changed on Linux
Post by: marcov on January 26, 2021, 09:16:51 am
RG?

(Reference Guide)
TinyPortal © 2005-2018