Recent

Author Topic: [Solved] C open() function in Lazarus?  (Read 3304 times)

Edson

  • Hero Member
  • *****
  • Posts: 1301
[Solved] C open() function in Lazarus?
« on: December 04, 2016, 04:53:06 am »
Can someone tell me please, if there is (and what is) some equivalent in fpc/lazarus, to the system C function open()?

It's declared something like:  int open (const char *__file, int __oflag, ...)

I need to port a C code in linux OS.
« Last Edit: December 05, 2016, 03:56:11 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

derek.john.evans

  • Guest
Re: C open() function in Lazarus?
« Reply #1 on: December 04, 2016, 05:11:39 am »
In SysUtils; FileOpen/FileClose/FileRead/FileWrite

http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html

Are close to 100% compatible.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: C open() function in Lazarus?
« Reply #2 on: December 04, 2016, 05:14:20 am »
I need to port a C code in linux OS.
Lots of unix (linux) functions are fp- prefixed are declared in BaseUnix  / Unix units.

If you're not planning to target Windows in future (or writing unix specific) you could use whose!
For example C open() is fpopen in freepascal.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: C open() function in Lazarus?
« Reply #3 on: December 04, 2016, 08:20:21 am »
I think you are not referring to a C Open() function perse, but to the unix fs open(). That's indeed as skalogryz wrote simply
Code: Pascal  [Select][+][-]
  1.  FpOpen('/path/to/device/file');

Note that FileOpen/FileClose/FileRead/FileWrite are cross platform, indeed, but under unix happen to use the FP prefixed functions from ./rtl/baseunix.pp like the above.
Filestreams do the same.
« Last Edit: December 04, 2016, 08:28:24 am by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018