Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: FPC + Mac file handling

  1. #1

    FPC + Mac file handling

    I've mentioned somewhere here before that I've been able to put OS X in a VM a long while back, and recently I have gotten XCode + FPC/Lazarus working happily.

    I'm having trouble trying to get my Tiled project to work under OS X (http://www.pascalgamedevelopment.com...ng-(with-ZenGL)

    Has anyone been able to? It dies on the line 67 "AssignFile(mapfile, fname);" with a file not found error. I did a fileexists on the file, and indeed for some reason it cannot find the file! I have literally copied this file everywhere -- every subdirectory of the .app, and the root directory the .app is in. I've even tried appending "./" to the filename, with no luck. While ZenGL doesn't complain about whether or not it can find the other resources (which are loaded before this map file is opened), I have no way to tell if it really loaded them successfully yet ;P

    Summary: How do I access files, and where do they go under OS X. If I specify a full path to the file, it will run happily, but I would much prefer relative paths for actual distribution.

  2. #2
    Quote Originally Posted by dazappa
    While ZenGL doesn't complain about whether or not it can find the other resources (which are loaded before this map file is opened)
    Emm... You can get path to YourApp.app/ via zgl_Get and constant DIRECTORY_APP(see demo01). ZenGL by itself will look for resources in YourApp.app/Contents/Resources/, if you set relative paths for textures/etc.

    Quote Originally Posted by dazappa
    If I specify a full path to the file, it will run happily, but I would much prefer relative paths for actual distribution.
    You can try to use Chdir with path to YourApp.app, but I don't remember if it works. Also you can try to use ZenGL file_* functions
    Last edited by Andru; 18-04-2011 at 03:23 PM.

  3. #3
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    You wouldnt be using a \ for folders coming from the winows world would you? a \ on unix like systems is an 'ignore next character' type thing... I would double check that they are all / . I had a very similar problem when I first moved to linux
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  4. #4
    code_glitch
    problem is not in how you write the path... problem is in unavailability term "current path" in MacOS X for applications which are running from bundle

  5. #5
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Ah... But wouldnt that be the folder where the bin file is? Just like in Win and Linux?
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  6. #6
    Try to see if the .app isn't in reality a symbolic link

    You should never assume starting directory on any platform
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  7. #7
    Quote Originally Posted by code_glitch
    Ah... But wouldnt that be the folder where the bin file is? Just like in Win and Linux?
    Yes, it's just a folder, but you can't work with files using relative paths

  8. #8
    Quote Originally Posted by code_glitch View Post
    You wouldnt be using a \ for folders coming from the winows world would you? a \ on unix like systems is an 'ignore next character' type thing... I would double check that they are all / . I had a very similar problem when I first moved to linux
    Nope, you can see in my Tutorial source I use "map_csv.tmx" and the only thing else I tried was "./map_csv.tmx"
    Quote Originally Posted by JSoftware View Post
    Try to see if the .app isn't in reality a symbolic link

    You should never assume starting directory on any platform
    The default way Lazarus produces apps under OS X is a bit strange, but no that was not the problem I had to create the package myself though.

    What Andru suggested (using a ZenGL function to get a var DIRECTORY_APP) has worked for me in this instance, at least. (Nice of you to include that!)

    Victory!

    As you can see, things are just a tad slow in the VM, and with no hardware acceleration it goes even slower. (It's a nice touch having a software renderer in this instance though) But, the good news is now I can compile to Win/Lin/Mac with a little effort. I only have one other project I'm working on aside from my Isolated Empire remake and port to ZenGL, so I'll post about that in a few weeks most likely.

  9. #9
    I'm glad you got it working dazappa

    Quote Originally Posted by dazappa View Post
    I've mentioned somewhere here before that I've been able to put OS X in a VM a long while back, and recently I have gotten XCode + FPC/Lazarus working happily.
    dazappa, I don't suppose you could share how you did the OS X & VM? I really really want to try playing with a Mac and possibly do some programming too, but I don't have any Mac hardware..

    If you want, just PM me.

    cheers,
    Paul

  10. #10
    And for those people who will search answer without using ZenGL, here the source code:
    Code:
    uses
      MacOSAll;
    //
      var
        appBundle   : CFBundleRef;
        appCFURLRef : CFURLRef;
        appCFString : CFStringRef;
        appPath     : array[ 0..8191 ] of AnsiChar;
    begin
      appBundle   := CFBundleGetMainBundle();
      appCFURLRef := CFBundleCopyBundleURL( appBundle );
      appCFString := CFURLCopyFileSystemPath( appCFURLRef, kCFURLPOSIXPathStyle );
      CFStringGetFileSystemRepresentation( appCFString, @appPath[ 0 ], 8192 );
      appWorkDir  := appPath + '/';
    But if I remember right, ParamString(0) also will return something...

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •