Saving to application support folder.

  • Greetings!

    I wish to save some files to my application's support folder.
    is there a variable somewhere that would contain the full path to
    that folder or do i have
    to create the folder?

    if i have to create the folder is there a global variable that i ca
    query for the mane of my application?

    i know, this sounds stupid, and i know how to do it manually, but i'm
    just making sure i'm
    not coding something that is already there and that i could use.

    thank you !

    Sandro Noel
    <snoel...>
  • On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:

    > I wish to save some files to my application's support folder.
    > is there a variable somewhere that would contain the full path to
    > that folder or do i have
    > to create the folder?

    There isn't. Use FSFindFolder().

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • that's not really what i am loking for...
    i'm not searching for a system folder.

    i'm looking for my own application support folder.
    wich are usualy located into ~/library/application support/[ApName]
    i need to find the application name programatically instead of hard
    coding it,
    is that possible ?

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:

    >
    > On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >
    >> I wish to save some files to my application's support folder.
    >> is there a variable somewhere that would contain the full path to
    >> that folder or do i have
    >> to create the folder?
    >
    > There isn't. Use FSFindFolder().
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>
    >
    >
    >
    >
    >
  • On Oct 8, 2007, at 12:59 PM, Sandro Noel wrote:

    > that's not really what i am loking for...
    > i'm not searching for a system folder.
    >
    > i'm looking for my own application support folder.
    > wich are usualy located into ~/library/application support/[ApName]
    > i need to find the application name programatically instead of hard
    > coding it,
    > is that possible ?

    Yes, and you should use FSFindFolder(). Seriously. FSFindFolder() is
    capable of returning the path to the user's Application Support folder.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • > Yes, and you should use FSFindFolder(). Seriously. FSFindFolder()
    > is capable of returning the path to the user's Application Support
    > folder.
    yea, i figured that with the documentation ... and thank you for the
    pointer.

    here is my second question.
    >> i need to find the application name programatically instead of
    >> hard coding it,

    thank you !

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:01 PM, Nick Zitzmann wrote:

    >
    > On Oct 8, 2007, at 12:59 PM, Sandro Noel wrote:
    >
    >> that's not really what i am loking for...
    >> i'm not searching for a system folder.
    >>
    >> i'm looking for my own application support folder.
    >> wich are usualy located into ~/library/application support/[ApName]
    >> i need to find the application name programatically instead of
    >> hard coding it,
    >> is that possible ?
    >
    > Yes, and you should use FSFindFolder(). Seriously. FSFindFolder()
    > is capable of returning the path to the user's Application Support
    > folder.
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>
    >
    >
    >
    >
    >
  • /**
        Returns the support folder for the application, used to store the
    Core Data
        store file.  This code uses a folder named "FinancialAid" for
        the content, either in the NSApplicationSupportDirectory location
    or (if the
        former cannot be found), the system's temporary directory.
      */

    - (NSString *)applicationSupportFolder {

        NSArray *paths =
    NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
    NSUserDomainMask, YES);
        NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:
    0] : NSTemporaryDirectory();
        return [basePath
    stringByAppendingPathComponent:@"ApplicationName"];
    }

    from my application delegate ( created by xcode )

    On Oct 8, 2007, at 1:59 PM, Sandro Noel wrote:

    > that's not really what i am loking for...
    > i'm not searching for a system folder.
    >
    > i'm looking for my own application support folder.
    > wich are usualy located into ~/library/application support/[ApName]
    > i need to find the application name programatically instead of hard
    > coding it,
    > is that possible ?
    >
    >
    > Sandro Noel
    > <snoel...>
    >
    >
    >
    > On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:
    >
    >>
    >> On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >>
    >>> I wish to save some files to my application's support folder.
    >>> is there a variable somewhere that would contain the full path to
    >>> that folder or do i have
    >>> to create the folder?
    >>
    >> There isn't. Use FSFindFolder().
    >>
    >> Nick Zitzmann
    >> <http://www.chronosnet.com/>
    >>
    >>
    >>
    >>
    >>

  • thank you for the snippet, really cool.

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:05 PM, Hasani Hunter wrote:

    >
    >
    > /**
    > Returns the support folder for the application, used to store
    > the Core Data
    > store file.  This code uses a folder named "FinancialAid" for
    > the content, either in the NSApplicationSupportDirectory
    > location or (if the
    > former cannot be found), the system's temporary directory.
    > */
    >
    > - (NSString *)applicationSupportFolder {
    >
    > NSArray *paths = NSSearchPathForDirectoriesInDomains
    > (NSApplicationSupportDirectory, NSUserDomainMask, YES);
    > NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:
    > 0] : NSTemporaryDirectory();
    > return [basePath
    > stringByAppendingPathComponent:@"ApplicationName"];
    > }
    >
    > from my application delegate ( created by xcode )
    >
    > On Oct 8, 2007, at 1:59 PM, Sandro Noel wrote:
    >
    >> that's not really what i am loking for...
    >> i'm not searching for a system folder.
    >>
    >> i'm looking for my own application support folder.
    >> wich are usualy located into ~/library/application support/[ApName]
    >> i need to find the application name programatically instead of
    >> hard coding it,
    >> is that possible ?
    >>
    >>
    >> Sandro Noel
    >> <snoel...>
    >>
    >>
    >>
    >> On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:
    >>
    >>>
    >>> On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >>>
    >>>> I wish to save some files to my application's support folder.
    >>>> is there a variable somewhere that would contain the full path
    >>>> to that folder or do i have
    >>>> to create the folder?
    >>>
    >>> There isn't. Use FSFindFolder().
    >>>
    >>> Nick Zitzmann
    >>> <http://www.chronosnet.com/>
    >>>
    >>>
    >>>
    >>>
    >>>

    >
  • On Oct 8, 2007, at 11:59 AM, Sandro Noel wrote:

    > i need to find the application name programatically instead of hard
    > coding it,

    I don't think you should assume that an Application used an
    application support folder based on its name.  That is likely to break
    depending on what you are doing.

    For example, Snak 1.0 used Snak as its folder name in app support, but
    snak 5 used "Snak 5" even though the app name was still Snak.
  • > from my application delegate ( created by xcode )

    Really, this code is generaed by XCode?
    where ?

    thank you !

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:05 PM, Hasani Hunter wrote:

    >
    >
    > /**
    > Returns the support folder for the application, used to store
    > the Core Data
    > store file.  This code uses a folder named "FinancialAid" for
    > the content, either in the NSApplicationSupportDirectory
    > location or (if the
    > former cannot be found), the system's temporary directory.
    > */
    >
    > - (NSString *)applicationSupportFolder {
    >
    > NSArray *paths = NSSearchPathForDirectoriesInDomains
    > (NSApplicationSupportDirectory, NSUserDomainMask, YES);
    > NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:
    > 0] : NSTemporaryDirectory();
    > return [basePath
    > stringByAppendingPathComponent:@"ApplicationName"];
    > }
    >
    > from my application delegate ( created by xcode )
    >
    > On Oct 8, 2007, at 1:59 PM, Sandro Noel wrote:
    >
    >> that's not really what i am loking for...
    >> i'm not searching for a system folder.
    >>
    >> i'm looking for my own application support folder.
    >> wich are usualy located into ~/library/application support/[ApName]
    >> i need to find the application name programatically instead of
    >> hard coding it,
    >> is that possible ?
    >>
    >>
    >> Sandro Noel
    >> <snoel...>
    >>
    >>
    >>
    >> On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:
    >>
    >>>
    >>> On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >>>
    >>>> I wish to save some files to my application's support folder.
    >>>> is there a variable somewhere that would contain the full path
    >>>> to that folder or do i have
    >>>> to create the folder?
    >>>
    >>> There isn't. Use FSFindFolder().
    >>>
    >>> Nick Zitzmann
    >>> <http://www.chronosnet.com/>
    >>>
    >>>
    >>>
    >>>
    >>>

    >
  • Sandro,

    Just create a new Cocoa Core Data application and check the
    application delegate that's created automatically

    Cheers
    Hasani

    On Oct 8, 2007, at 2:10 PM, Sandro Noel wrote:

    >> from my application delegate ( created by xcode )
    >
    > Really, this code is generaed by XCode?
    > where ?
    >
    > thank you !
    >
    >
    > Sandro Noel
    > <snoel...>
    >
    >
    >
    > On 8-Oct-07, at 3:05 PM, Hasani Hunter wrote:
    >
    >>
    >>
    >> /**
    >> Returns the support folder for the application, used to store
    >> the Core Data
    >> store file.  This code uses a folder named "FinancialAid" for
    >> the content, either in the NSApplicationSupportDirectory
    >> location or (if the
    >> former cannot be found), the system's temporary directory.
    >> */
    >>
    >> - (NSString *)applicationSupportFolder {
    >>
    >> NSArray *paths =
    >> NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
    >> NSUserDomainMask, YES);
    >> NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:
    >> 0] : NSTemporaryDirectory();
    >> return [basePath
    >> stringByAppendingPathComponent:@"ApplicationName"];
    >> }
    >>
    >> from my application delegate ( created by xcode )
    >>
    >> On Oct 8, 2007, at 1:59 PM, Sandro Noel wrote:
    >>
    >>> that's not really what i am loking for...
    >>> i'm not searching for a system folder.
    >>>
    >>> i'm looking for my own application support folder.
    >>> wich are usualy located into ~/library/application support/[ApName]
    >>> i need to find the application name programatically instead of
    >>> hard coding it,
    >>> is that possible ?
    >>>
    >>>
    >>> Sandro Noel
    >>> <snoel...>
    >>>
    >>>
    >>>
    >>> On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:
    >>>
    >>>>
    >>>> On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >>>>
    >>>>> I wish to save some files to my application's support folder.
    >>>>> is there a variable somewhere that would contain the full path
    >>>>> to that folder or do i have
    >>>>> to create the folder?
    >>>>
    >>>> There isn't. Use FSFindFolder().
    >>>>
    >>>> Nick Zitzmann
    >>>> <http://www.chronosnet.com/>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>

    >>
    >
  • Hasani ! Many Thanks!

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:12 PM, Hasani Hunter wrote:

    > Sandro,
    >
    > Just create a new Cocoa Core Data application and check the
    > application delegate that's created automatically
    >
    > Cheers
    > Hasani
    >
    > On Oct 8, 2007, at 2:10 PM, Sandro Noel wrote:
    >
    >>> from my application delegate ( created by xcode )
    >>
    >> Really, this code is generaed by XCode?
    >> where ?
    >>
    >> thank you !
    >>
    >>
    >> Sandro Noel
    >> <snoel...>
    >>
    >>
    >>
    >> On 8-Oct-07, at 3:05 PM, Hasani Hunter wrote:
    >>
    >>>
    >>>
    >>> /**
    >>> Returns the support folder for the application, used to store
    >>> the Core Data
    >>> store file.  This code uses a folder named "FinancialAid" for
    >>> the content, either in the NSApplicationSupportDirectory
    >>> location or (if the
    >>> former cannot be found), the system's temporary directory.
    >>> */
    >>>
    >>> - (NSString *)applicationSupportFolder {
    >>>
    >>> NSArray *paths = NSSearchPathForDirectoriesInDomains
    >>> (NSApplicationSupportDirectory, NSUserDomainMask, YES);
    >>> NSString *basePath = ([paths count] > 0) ? [paths
    >>> objectAtIndex:0] : NSTemporaryDirectory();
    >>> return [basePath
    >>> stringByAppendingPathComponent:@"ApplicationName"];
    >>> }
    >>>
    >>> from my application delegate ( created by xcode )
    >>>
    >>> On Oct 8, 2007, at 1:59 PM, Sandro Noel wrote:
    >>>
    >>>> that's not really what i am loking for...
    >>>> i'm not searching for a system folder.
    >>>>
    >>>> i'm looking for my own application support folder.
    >>>> wich are usualy located into ~/library/application support/[ApName]
    >>>> i need to find the application name programatically instead of
    >>>> hard coding it,
    >>>> is that possible ?
    >>>>
    >>>>
    >>>> Sandro Noel
    >>>> <snoel...>
    >>>>
    >>>>
    >>>>
    >>>> On 8-Oct-07, at 2:47 PM, Nick Zitzmann wrote:
    >>>>
    >>>>>
    >>>>> On Oct 8, 2007, at 12:44 PM, Sandro Noel wrote:
    >>>>>
    >>>>>> I wish to save some files to my application's support folder.
    >>>>>> is there a variable somewhere that would contain the full path
    >>>>>> to that folder or do i have
    >>>>>> to create the folder?
    >>>>>
    >>>>> There isn't. Use FSFindFolder().
    >>>>>
    >>>>> Nick Zitzmann
    >>>>> <http://www.chronosnet.com/>
    >>>>>
    >>>>>
    >>>>>
    >>>>>
    >>>>>

    >>>
    >>
    >
  • reading more and more documentation i now find out that the
    terminology i used was wrong.
    what I am looking for is the bundle name... ( gotta get used to all
    the name changes :) )...
    Like a "sheet" being a Message Box,(ok much more flexible i admit )
    my god did i look hard for that one.. :)
    anyways.

    I believe, but i might be wrong... the name should remain the same
    and versioning differences should happen inside the application folder.
    for example.

    ~/......./Application Support/AppName/
    in here version independent support files
    ~/......./Application Support/AppName/1.0
    in here 1.0 support files.
    ~/......./Application Support/AppName/5.0
    in here 5.0 support files.

    this way as your application evolves you still have access to the
    application's suport fiels going back to it's origins if need be.
    and it also allows for multiple version of the same application to
    work side by side, if the whole thing is designed properly.
    ( if installed in different locations of course )

    just my view...
    Thanks for warning as i said i might be wrong.

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:09 PM, Steven W Riggins wrote:

    >
    > On Oct 8, 2007, at 11:59 AM, Sandro Noel wrote:
    >
    >> i need to find the application name programatically instead of
    >> hard coding it,
    >
    > I don't think you should assume that an Application used an
    > application support folder based on its name.  That is likely to
    > break depending on what you are doing.
    >
    > For example, Snak 1.0 used Snak as its folder name in app support,
    > but snak 5 used "Snak 5" even though the app name was still Snak.
    >
  • You can't count on being able to write to your own bundle. You'll
    need to find some other way of doing whatever you're trying to do.

    _murat

    On Oct 8, 2007, at 12:35 PM, Sandro Noel wrote:

    > reading more and more documentation i now find out that the
    > terminology i used was wrong.
    > what I am looking for is the bundle name...
  • I'm not trying to write to my bundle Sorry i must of missed typing a
    word ...
    I want to find out the name of the bundle, or application so i can
    append that name to the
    string I will use to create the application support Path.
    I just didn't want to hard code it.

    so I'm looking for the application's name [application.app] without
    the "app"

    thank you

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 3:51 PM, Murat Konar wrote:

    > You can't count on being able to write to your own bundle. You'll
    > need to find some other way of doing whatever you're trying to do.
    >
    > _murat
    >
    > On Oct 8, 2007, at 12:35 PM, Sandro Noel wrote:
    >
    >> reading more and more documentation i now find out that the
    >> terminology i used was wrong.
    >> what I am looking for is the bundle name...
    >
    >
  • On Oct 8, 2007, at 2:55 PM, Sandro Noel wrote:

    > I'm not trying to write to my bundle Sorry i must of missed typing
    > a word ...
    > I want to find out the name of the bundle, or application so i can
    > append that name to the
    > string I will use to create the application support Path.
    > I just didn't want to hard code it.
    >
    > so I'm looking for the application's name [application.app] without
    > the "app"

    I use:

    [[NSBundle mainBundle] objectForInfoDictionaryKey:
    @"CFBundleExecutable"]

    This has the advantage over using the name of the application bundle
    that if the user renames the app, this value remains unchanged.

    Glenn Andreas                      <gandreas...>
      <http://www.gandreas.com/> wicked fun!
    quadrium2 | build, mutate, evolve, animate  | images, textures,
    fractals, art
  • >
    > so I'm looking for the application's name [application.app] without
    > the "app"
    >

    I'm far far away from XCode / Apple documentation, but what about
    reading  the app info.plist ?

    :: marcelo.alves - Where was life when it had a meaning ?
  • Glen

    now THAT's what I'm talking about!
    many many thanks!

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 4:03 PM, glenn andreas wrote:

    >
    > On Oct 8, 2007, at 2:55 PM, Sandro Noel wrote:
    >
    >> I'm not trying to write to my bundle Sorry i must of missed typing
    >> a word ...
    >> I want to find out the name of the bundle, or application so i can
    >> append that name to the
    >> string I will use to create the application support Path.
    >> I just didn't want to hard code it.
    >>
    >> so I'm looking for the application's name [application.app]
    >> without the "app"
    >
    > I use:
    >
    > [[NSBundle mainBundle] objectForInfoDictionaryKey:
    > @"CFBundleExecutable"]
    >
    > This has the advantage over using the name of the application
    > bundle that if the user renames the app, this value remains unchanged.
    >
    >
    > Glenn Andreas                      <gandreas...>
    > <http://www.gandreas.com/> wicked fun!
    > quadrium2 | build, mutate, evolve, animate  | images, textures,
    > fractals, art
    >
    >
    >
  • Thank you all for sharing your knowledge with me on this issue.
    Your help is greatly appreciated!

    Sandro Noel
    <snoel...>
  • On Oct 8, 2007, at 1:03 PM, glenn andreas wrote:

    >
    > On Oct 8, 2007, at 2:55 PM, Sandro Noel wrote:
    >
    >> I'm not trying to write to my bundle Sorry i must of missed typing
    >> a word ...
    >> I want to find out the name of the bundle, or application so i can
    >> append that name to the
    >> string I will use to create the application support Path.
    >> I just didn't want to hard code it.
    >>
    >> so I'm looking for the application's name [application.app]
    >> without the "app"
    >
    > I use:
    >
    > [[NSBundle mainBundle] objectForInfoDictionaryKey:
    > @"CFBundleExecutable"]
    >
    > This has the advantage over using the name of the application
    > bundle that if the user renames the app, this value remains unchanged.
    >
    >
    > Glenn Andreas                      <gandreas...>
    > <http://www.gandreas.com/> wicked fun!
    > quadrium2 | build, mutate, evolve, animate  | images, textures,
    > fractals, art
    >

    Hi,

    Just out of curiosity, is there a reason not to use Apple's constant
    kCFBundleExecutableKey, instead of the string literal
    @"CFBundleExecutable"?

    as in...

        [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)
    kCFBundleExecutableKey]

    Cheers,
        Andrew
  • On Oct 8, 2007, at 3:27 PM, Andrew Merenbach wrote:

    >> I use:
    >>
    >> [[NSBundle mainBundle] objectForInfoDictionaryKey:
    >> @"CFBundleExecutable"]
    >>
    >> This has the advantage over using the name of the application
    >> bundle that if the user renames the app, this value remains
    >> unchanged.
    >>
    > Just out of curiosity, is there a reason not to use Apple's
    > constant kCFBundleExecutableKey, instead of the string literal
    > @"CFBundleExecutable"?
    >
    > as in...
    >
    > [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)
    > kCFBundleExecutableKey]

    Using kCFBundleExecutableKey requires including <Carbon.h> and
    linking Carbon.framework (or at least CoreFoundation), where as the
    string constant requires no extra inclusion or linker requirements
    (nor the explicit reinterpretation cast).

    The constant is less error prone, but requires remembering extra "oh,
    yeah, I've got to do this".  Six of one, half a dozen of the other...

    Glenn Andreas                      <gandreas...>
      <http://www.gandreas.com/> wicked fun!
    quadrium | flame : flame fractals & strange attractors : build,
    mutate, evolve, animate
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today