Sign in Join

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

Mailing lists / fpc-pascal / 2015-03

the unexplained 666

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner

Hi,

Today I stumbled (again) over TFileStream and it contains the constant 438:

constructor TFileStream.Create(const AFileName: string; Mode: Word);
begin
  Create(AFileName,Mode,438);
end;

You need several searches to find out what the 438 actually is.

For example its fpdoc page does not explains it:
http://lazarus-ccr.sourceforge.net/docs/rtl/classes/tfilestream.create.html

Same for the called FileCreate:
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/filecreate.html

Under Windows the Rights are not used.
Under Unix it calls fpOpen, which only tells about "permissions": http://lazarus-ccr.sourceforge.net/docs/rtl/baseunix/fpopen.html

Then it calls 'FPC_SYSC_OPEN', which under Linux calls syscall 'open', which after a search reveals, that the mode is a bit field using the S_I* constants, which are usually written in binary, octal or hexadecimal.

The octal value of 438 is &666, which is read/write permissions for other/group/owner.

Why not write &666? Maybe some religious reasons? ;)

Mattias

Reply by email

Wolfe, Robert
to Mattias Gaertner

Could be.

Earlier message 41 lines
-----Original Message----- From: On Behalf Of Mattias Gaertner Sent: Sunday, March 1, 2015 7:52 AM To: Subject: [fpc-pascal] the unexplained 666 Hi, Today I stumbled (again) over TFileStream and it contains the constant 438: constructor TFileStream.Create(const AFileName: string; Mode: Word); begin Create(AFileName,Mode,438); end; You need several searches to find out what the 438 actually is. For example its fpdoc page does not explains it: http://lazarus-ccr.sourceforge.net/docs/rtl/classes/tfilestream.create.html Same for the called FileCreate: http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/filecreate.html Under Windows the Rights are not used. Under Unix it calls fpOpen, which only tells about "permissions": http://lazarus-ccr.sourceforge.net/docs/rtl/baseunix/fpopen.html Then it calls 'FPC_SYSC_OPEN', which under Linux calls syscall 'open', which after a search reveals, that the mode is a bit field using the S_I* constants, which are usually written in binary, octal or hexadecimal. The octal value of 438 is &666, which is read/write permissions for other/group/owner. Why not write &666? Maybe some religious reasons? ;) Mattias

Reply by email

Mattias Gaertner
to Marco van de Voort
In our previous episode, Mattias Gaertner said: > Why not write &666? Maybe some religious reasons? ;) No, simply that octal literal support is newer than the *nix rtl.

ok, although then again: When came binary and hexadecimal?

If you want to work on this, please fix the constants in the FreeBSD console unit too, there are another couple of hundred such cases there :-)

My main concern was the lack of comments/documentation.

Mattias

Reply by email

Mark Morgan Lloyd
to Mattias Gaertner: Today I stumbled (again) over TFileStream and it contains the constant 438: constructor…
Mattias Gaertner wrote 10 lines
constructor TFileStream.Create(const AFileName: string; Mode: Word); begin Create(AFileName,Mode,438); end; The octal value of 438 is &666, which is read/write permissions for other/group/owner. Why not write &666? Maybe some religious reasons? ;)

Default radix for debugger variable display? Non-unix programmer not appreciating the "natural" way that the bits group?

/Anything's/ better than starting an argument over mysticism and gullibility exhibited by certain communities.

I find that Burroughs was using Octal in about 1960, which predates its popularisation by DEC etc. by some years.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marco van de Voort
to Mattias Gaertner: On Sun, 1 Mar 2015 16:11:06 +0100 (CET) ok, although then again: When came binary and…
Mattias Gaertner wrote 7 lines
> In our previous episode, Mattias Gaertner said: > > Why not write &666? Maybe some religious reasons? ;) > > No, simply that octal literal support is newer than the *nix rtl. ok, although then again: When came binary and hexadecimal?

Decimal and hexadecimal from the start, octal and binary since early 1.9.x versions.

The *nix rtl is from christmas 2003. (1.1 versions)

Reply by email