How do I create a folder in a homebrew program?

Discussion in '3DS - Homebrew Development and Emulators' started by JackMacWindows, Dec 20, 2016.

  1. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    Hello,
    I know this seems like a stupid question, but I am wondering how I can make a directory from a homebrew program. I am writing a program that installs homebrew from zip files, but I need to know how to create a directory to install most 3DSX files. I saw FSUSER_CreateDirectory() in the libctru docs, but that mentions archives which I'm not sure about.

    JackMacWindows
     
  2. teseting

    teseting Newbie

    Newcomer
    1
    0
    Dec 17, 2016
    United States
    Do it the easy way and use
    Code:
     mkdir("/dir", 0777);
    also include
    Code:
    #include <dirent.h> // for more io features or you could just include <sys/stat.h> or <sys/iosupport.h>
    
    but if you want to do more IO stuff you should probably know how to properly
    Code:
     FS_Archive sdArch;// you want to reuse this so keep it
    Result Res = FSUSER_OpenArchive(&sdArch, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
    FSUSER_CreateDirectory(sdArch, fsMakePath(PATH_ASCII, path), 0);
    
    also just learn from other people as the code above was copied directly from
    https://github.com/J-D-K/JKSM/blob/e2b30c51c9c36a3289f8dd7584bd0ec18b9e5c48/source/sys.cpp
     
    Last edited by teseting, Dec 20, 2016