Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 13, 2008, 11:47 PM   #1
vishal.chauhan
macrumors newbie
 
Join Date: Feb 2008
How to get the current application dir path in Carbon?

Hi All,

I am used to c and c++ stuff but I am new to the carbon framework.
I want to know how to get current directory path in carbon and how to convert thar path to a const char*.

Thanks.
vishal.chauhan is offline   0 Reply With Quote
Old Feb 14, 2008, 12:11 AM   #2
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: Austin, TX
You can still use Unixy features in a Carbon app on OS X (since OS X has a Unixy core deep down inside), just do the getcwd() call as if you were not using Carbon. Just add #include <unistd.h> and have at it.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Feb 14, 2008, 05:30 AM   #3
gnasher729
macrumors G4
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by vishal.chauhan View Post
Hi All,

I am used to c and c++ stuff but I am new to the carbon framework.
I want to know how to get current directory path in carbon and how to convert thar path to a const char*.

Thanks.
"Current directory path" is quite a meaningless concept in Carbon applications. Better tell us what it actually is that you want to achieve.
gnasher729 is offline   0 Reply With Quote
Old Feb 14, 2008, 07:08 AM   #4
toddburch
macrumors 6502a
 
Join Date: Dec 2006
Location: Katy, Texas
Send a message via AIM to toddburch Send a message via MSN to toddburch
Would argv[0] include that information?

Todd
toddburch is offline   0 Reply With Quote
Old Feb 14, 2008, 09:08 AM   #5
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
Hm, since the OP's title includes "current application dir path" I'm inclined to think he's referring to the path of his Carbon application. If so, you can use CFBundleCopyBundleURL(CFBundleGetMainBundle()) which returns a CFURLRef which points to the .app bundle.
kainjow is offline   0 Reply With Quote
Old Feb 14, 2008, 11:28 PM   #6
vishal.chauhan
Thread Starter
macrumors newbie
 
Join Date: Feb 2008
Thanks.
I am exactly refering to the carbon application bundle and yes
CFBundleCopyBundleURL(CFBundleGetMainBundle()) is working fine.
vishal.chauhan is offline   0 Reply With Quote
Old Oct 29, 2009, 12:34 AM   #7
arjit
macrumors newbie
 
Join Date: Feb 2009
Quote:
Originally Posted by vishal.chauhan View Post
Thanks.
I am exactly refering to the carbon application bundle and yes
CFBundleCopyBundleURL(CFBundleGetMainBundle()) is working fine.
This gives me the full application path not the parent directory .... is there is a function to do that ?
arjit is offline   0 Reply With Quote
Old Oct 29, 2009, 01:16 AM   #8
chown33
macrumors 601
 
Join Date: Aug 2009
Quote:
Originally Posted by toddburch View Post
Would argv[0] include that information?
No. argv[0] typically contains the full path of the executable, but that's only a convention, not a requirement. The full path of the executable doesn't have anything to do with the current working directory. If it did, then /bin/pwd would never work.
chown33 is offline   0 Reply With Quote
Old Oct 29, 2009, 01:05 PM   #9
idelovski
macrumors regular
 
Join Date: Sep 2008
Quote:
Originally Posted by arjit View Post
.... is there is a function to do that ?
I use CFURLGetFSRef() to convert url to FSRef and then:
Code:
OSErr osErr = FSGetCatalogInfo (&fileFSRef, kFSCatInfoNone, NULL, NULL, NULL, &parentFSRef);
would give FSRef of parent folder.
idelovski is offline   0 Reply With Quote
Old Oct 29, 2009, 02:17 PM   #10
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by arjit View Post
This gives me the full application path not the parent directory .... is there is a function to do that ?
Use CFURLCreateCopyDeletingLastPathComponent()
kainjow is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
TUTORIAL: How to get PCSX2 to run on Mac(without Bootcamp) Mirrors Mac Applications and Mac App Store 21 Mar 14, 2013 03:34 PM
Does anybody know how to get TweetTask? xmelissaxmayhem Jailbreaks and iOS Hacks 3 Jul 3, 2011 01:21 AM
How to get the path of bundle application Tank2005 Mac Programming 2 Jan 20, 2011 02:44 AM
Tip: How to get the Size column (and others) in Snow Leopard's search results list. Casiotone Mac OS X 0 Sep 3, 2009 10:32 PM
how to get the value of class variable in a non member function? chidambaram Mac Programming 8 Apr 10, 2008 11:13 PM


All times are GMT -5. The time now is 09:34 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC