Recent

Author Topic: Equivalent of "FpChmod" in OSX?  (Read 6159 times)

aidv

  • Full Member
  • ***
  • Posts: 173
Equivalent of "FpChmod" in OSX?
« on: August 29, 2015, 03:48:18 pm »
Hi all!

What is the equivalent of "FpChmod" in OSX?

I need to be able to change the permissions of a directory if needed programatically.

"FpChmod" seems to only work in Linux.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Equivalent of "FpChmod" in OSX?
« Reply #1 on: August 29, 2015, 04:28:36 pm »
fpchmod works in OS X too. Did you include unit "Unix" ?

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Equivalent of "FpChmod" in OSX?
« Reply #2 on: August 29, 2015, 05:09:29 pm »
fpchmod works in OS X too. Did you include unit "Unix" ?

Yes I did but it keeps telling me that the unit Unix can't be found.

Matter of fact, many of the units don't seem to be found, yet I can compile and run the app without problems.

The problem also occurs when pressing Ctrl+Space

What might be the problem?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Equivalent of "FpChmod" in OSX?
« Reply #3 on: August 29, 2015, 05:12:08 pm »
Something wrong with your install or configuration, involving the -Fu "unit" path. But since the unix unit is in the core RTL, about nothing should work!?!?


lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Equivalent of "FpChmod" in OSX?
« Reply #4 on: August 29, 2015, 05:26:12 pm »
fpchmod works in OS X too. Did you include unit "Unix" ?

@aidv
Try unit "baseunix" and reply.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Equivalent of "FpChmod" in OSX?
« Reply #5 on: August 29, 2015, 05:29:48 pm »
Stupid me, indeed baseunix. Still, unit "unix" should be found normally.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Equivalent of "FpChmod" in OSX?
« Reply #6 on: August 29, 2015, 05:51:24 pm »
Stupid me, indeed baseunix. Still, unit "unix" should be found normally.

   If the unit would have been found automatically then wouldn't default written code become platform dependant!?  :-\ You know... "Write once, compile anywhere".

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Equivalent of "FpChmod" in OSX?
« Reply #7 on: August 29, 2015, 06:24:27 pm »
Stupid me, indeed baseunix. Still, unit "unix" should be found normally.

   If the unit would have been found automatically then wouldn't default written code become platform dependant!?  :-\ You know... "Write once, compile anywhere".

It is interesting how you would like to set unix permissions in a platform independent way.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Equivalent of "FpChmod" in OSX?
« Reply #8 on: August 29, 2015, 07:16:43 pm »
It is interesting how you would like to set unix permissions in a platform independent way.

   :)
   Indeed, for those that read this forum topic only, I think I've skipped some steps that make my reply out of context.  %)
   At the time I've written the text I've also sent a PM and also I've had a fresh forum post, related to this subject.
   You may improve a cross platform file attributes/permissions code related code at: http://forum.lazarus.freepascal.org/index.php/topic,29368.msg186428.html#msg186428
   Best wishes!

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Equivalent of "FpChmod" in OSX?
« Reply #9 on: August 30, 2015, 01:49:14 am »
BaseUnix seems to work, but now it cant find the mode S_IRWXO.

And when right-clicking on FpChmod or pressing Ctrl+Space, it says that BaseUnix can't be found.

What the F!#? is going on? I'm having a freak-out here right now I can't wrap my head around it.

When I Comment out the line of code that uses FpChmod and leave BaseUnix in the uses clause the app still compiles?!?

Edit:

Problem solved, I had to rescan FPC Source Directory, and now Ctrl+Space work, but S_IRWXO still can't be found.
« Last Edit: August 30, 2015, 02:01:58 am by aidv »

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Equivalent of "FpChmod" in OSX?
« Reply #10 on: August 30, 2015, 09:15:18 am »
Problem solved, I had to rescan FPC Source Directory, and now Ctrl+Space work, but S_IRWXO still can't be found.

   I remember I've had the same problem. As a workaround I've replaced the constants(like S_IRWXO) with numbers(like 755). At that time I've noticed that even fpc's fcl and rtl were using such numbers instead of constants.

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Equivalent of "FpChmod" in OSX?
« Reply #11 on: August 30, 2015, 03:08:53 pm »
Problem solved, I had to rescan FPC Source Directory, and now Ctrl+Space work, but S_IRWXO still can't be found.

   I remember I've had the same problem. As a workaround I've replaced the constants(like S_IRWXO) with numbers(like 755). At that time I've noticed that even fpc's fcl and rtl were using such numbers instead of constants.

Yep, 755 compiles. Thanks for that.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Equivalent of "FpChmod" in OSX?
« Reply #12 on: August 30, 2015, 03:14:43 pm »
IIRC there are a few S_ constants required by POSIX, and combinations can be made by ORring them.

However some *nixes have some combinations predefined, but this is not standard.

 

TinyPortal © 2005-2018