|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Developer Tools
I'm having trouble opening files in the resource folder with one of my C++ programs.
I have it compiled and all of the resources where included in the resource fork of the app, but when I try to reference them by name, say I have a file called sample.txt and so if I use fopen( "sample.txt" ), or a like command to open files, it doesn't read the data and just returns NULL. It does open it if I use the entire system path such as fopen( "/Users/damitrious/Desktop/blah/blah" ). But this is terribly unconvenient being that I don't want to specify a directory to install the app in. So is there any way to make teh compiler look in the resource directory where it should look, or am I missing something? |
|
#2
|
||||
|
||||
|
I'm not sure about the compiler options, but you should be able to use a relative path to the resource. Note that the path is relative to the your programs binary – the relative path should be something like ../Resources/sample.txt
Cocoa has a class for working with the contents of a bundle called NSBundle which would usually be used for this kind of thing. Give that a go, hope it helps .Mark.
__________________
... > (define links (list google scheme ruby python others ...)) ; Read my blog at http://netytan.blogspot.com/. > _
|
|
#3
|
|||
|
|||
|
So I got around to finding where the error was with Debugger and it seems it is unable to access the memory.
![]() I am not a Cocoa person yet, though I intend to get to it in the summer, so I am using a library that hides the underbelly of Cocoa. This is what came up in the Debugger, and if anyone can tell me anything about it, that would be great. Code:
Printing description of q: Program received signal SIGINT, Interrupt. 0x901634b0 in CFShow () The program being debugged was signaled while in a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior use "set unwindonsignal on" Evaluation of the expression containing the function (CFShow) will be abandoned. (gdb) |
|
#4
|
||||
|
||||
|
I can't tell you what the Message means exactly however it seems to have received a keyboard interrupt (Ctrl-C).
If you’re using the Carbon then you should have access to CFBundle - the Carbon version of Cocoa's NSBundle. This is located in the Core Foundation framework. Really not sure why the relative path didn't work though .Mark. |
|
#5
|
|||
|
|||
|
Hmmm that is odd.
I know this is probably not useful, but it looks like project builder is putting the file in the correct place and is referenceing it correctly. When I open up one of the base files, namely the "username.pbxuser" I find the lines:
I think it is probably the library that I am using, and I am going to download the newest version, see if that helps any. Thanks for the effort netytan. |
|
#6
|
||||
|
||||
|
No problems Jose, I would suggest you take a closer look at the Carbon framework for developing Mac applications. This is written in C so it doesn't use OOP per say but from what I've read it's pretty nice to work with
.What framework are you using now anyway? Mark. |
|
#7
|
|||
|
|||
|
I'm using the allegro game library, that uses cocoa as the underlying code. I just use it because it allows me to write code for Mac, Win, Linux, Unix, etc. without changing a word.
I noticed there was a new version today, so I will dl it now; see if it fixes the problem. |
|
#8
|
|||
|
|||
|
Nope didn't seem to help, well for now, I'll just have to put all my resources in the Library/Application Support/ folder.
![]() This really wasn't the way I wanted to do it. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Mac Help > Developer Tools |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|