Permission denied problem

Discussion in 'Mac Programming' started by chidambaram, Sep 15, 2008.

  1. macrumors member

    Mar 9, 2008

    I am working in Carbon C application (Mac OS 10.4.7)

    I want to open a pdf file which is placed in the desktop using System command.

    My code is


    The output is permission denied

    What can i do to rectify this?

    Thanks in advance....
  2. macrumors 68040


    Jan 10, 2005
    Dallas, TX
    That isn't an executable file. You'll need to choose the program and pass the file as an argument, or use some other method to launch the file in the default application. I'm not sure how to do the latter with carbon.

  3. thread starter macrumors member

    Mar 9, 2008
    thanks for ur reply sir.

    You said "choose the program and select the file"

    Will u please explain this in detail and how can i do that?
  4. macrumors G5


    Nov 25, 2005
    1. This call to the "system" function would try to execute the file test1.pdf. Which you obviously can't, and if you could, you wouldn't want to.

    2. Since there is another thread about buffer overflows and security problems, I'd just say that the system function can lead to some rather nasty security holes.

    3. Have a look at the LaunchServices APIs. Especially LSOpenCFURLRef and LSOpenFSRef.
  5. Moderator emeritus


    Jul 24, 2002
    Everything gnasher729 said above is correct and you should really do 3) but if you want a quick and dirty fix try using

    system("open /Users/laserwords/Desktop/test1.pdf");
    This should call the command line open utility that will use Launch Services to open the file in the correct application...
  6. thread starter macrumors member

    Mar 9, 2008
    thanks for ur reply

    system function with open keyword is working fine.

    please give some sample code for LSOpenFSRef() and LSOpenCFURLRef()

Share This Page