Mac Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsMac Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 2nd, 2005, 11:03 PM
jose_e_cuervo jose_e_cuervo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 49 jose_e_cuervo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 52 m 25 sec
Reputation Power: 4
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?

Reply With Quote
  #2  
Old March 3rd, 2005, 03:50 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,479 netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 39 m 48 sec
Reputation Power: 46
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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/.
> _



Reply With Quote
  #3  
Old March 3rd, 2005, 07:56 PM
jose_e_cuervo jose_e_cuervo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 49 jose_e_cuervo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 52 m 25 sec
Reputation Power: 4
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) 

Reply With Quote
  #4  
Old March 5th, 2005, 12:51 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,479 netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 39 m 48 sec
Reputation Power: 46
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #5  
Old March 6th, 2005, 08:04 PM
jose_e_cuervo jose_e_cuervo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 49 jose_e_cuervo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 52 m 25 sec
Reputation Power: 4
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:

  • 002C935807C7076900085DB3 = {
    isa = PBXFileReference;
    name = sample.txt;
    path = /Users/damitrious/Desktop/RevengeofSphere/build/RevengeofSphere.app/Contents/Resources/sample.txt;
    refType = 0;
    };

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.

Reply With Quote
  #6  
Old March 7th, 2005, 07:40 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,479 netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level)netytan User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 39 m 48 sec
Reputation Power: 46
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #7  
Old March 7th, 2005, 06:38 PM
jose_e_cuervo jose_e_cuervo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 49 jose_e_cuervo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 52 m 25 sec
Reputation Power: 4
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.

Reply With Quote
  #8  
Old March 8th, 2005, 06:47 PM
jose_e_cuervo jose_e_cuervo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 49 jose_e_cuervo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 52 m 25 sec
Reputation Power: 4
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsMac Help > Developer Tools


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway