I'm new in osx programming. Tryed following:

I'm new in osx programming. Tryed following:

TFile.Exists( '/Applications/mytest.app' )

It returns always false.
Something with my path must be wrong.
Can somebody point me to the right direction?

Comments

  1. That's because you are actually testing for the existence of a directory, not a file - it's only the Finder UI that makes it look like a file. It's a bit like how the Explorer UI makes a ZIP file appear to be a directory, only the other way round.

    ReplyDelete
  2. By the by, you can see the reality of a .app bundle in Terminal - enter the command, ls -F /Applications, and you'll find all the .app entries come up with a slash at the end, unless you've got any shortcuts ('aliases' on Mac parlance), which will be indicated with an @ sign instead.

    ReplyDelete
  3. Said another way, .app bundles in OS X are folders, not files. Also, remember that OS X is a Unix-based OS, so some of the things you know and love (or hate) about Windows won't be there or will be slightly different.

    ReplyDelete
  4. I can suggest you buy the book Delphi XE2 Foundations - Part 2 and have a look at Chapter 7 - Working with the file system and Working with directories and paths. It explains the difference in thinking between writing a Windows app vs a OSX, Android and iOS app. It also shows how to obtain the different directories on the different OSes. In general, I would recommend these books to all multi-device Delphi developers.
    I just wish the author would bring out an update on the books to show where things have changed since XE2. Most chapters would stay relevant, like the topic discussed here, but some others might have better ways or newer ways of working. That said, still a 5-star rating in my opinion.

    ReplyDelete
  5. Thanks to all for the helpful answers.
    Of course, xx.app its a directory not a file. I should now that. Thanks also for the book tip.

    ReplyDelete
  6. Scott Pinkham That was me. But i asked for some slightly different. However, i was seek and tired yesterday. Sorry for that.

    ReplyDelete
  7. Johan Swart Hmm, if that was a subtle hint that I hadn't got round to your email yet, check your inbox, because it worked... ;-)

    ReplyDelete

Post a Comment