Creating a new directory for output files

Discussion in 'Mac Programming' started by Fenrir, Mar 19, 2007.

  1. Fenrir macrumors newbie

    Mar 15, 2007
    I'm programming in C++, using Xcode as my development environment.

    I have a program that saves information in log files. Currently, all of the log files get put in the same directory as the executable. However, I'd like to put the log files in a new folder created by the program that corresponds to the user id.

    Is there a way to create a new folder when creating an output file?
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Note in one step. You'll have to create the folder then alter the path you are writing to. I'm not a C++ person so you'll have to wait for one to come along! I could help you in Java or Cocoa...
  3. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    I guess you could always use mkdir() and getuid() from stdio.h. Otherwise I think boost has some os independant file/directory manipulation stuff.

    b e n

Share This Page