Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Creating a new folder in documents directory — Gideros Forum

Creating a new folder in documents directory

kussakovkussakov Member
edited May 2012 in Game & application design

I want to create subdirectories in my documents ("|D|") directory where I want to save/delete some files.
I can't figure out which API to call to create a new directory.

Could you help please?




  • CarolineCaroline Guru
    edited May 2012
    @kussakov - I'm not 100% sure, but as no-one else has stepped in, I'll have a go, and bump the question anyway.

    I don't think you can. Googling "lua create folder", brings up a number of stackoverflow answers which state this in various ways:
    The Lua design philosophy is to be pure ISO C, so as to be portable to anything with a C compiler. There is no directory creation function in the C standard library. This is left up to platform-specific extensions, like mkdir(2) on POSIX systems and CreateDirectory*() on Windows.
    So I would guess that creating a folder is dependent upon which operating system you are using.

    You can easily do it through plugins. Have you tried plugins yet? Are you working on Android or iOS?
  • Thanks Caroline!
    I also googled a lot before adding the discussion :-)
    Bassically we should wait for next releases to create and browse directories.
  • ar2rsawseenar2rsawseen Maintainer
    Just an idea, but if you try to open file in write mode, which doesn't exist, it's automatically created right?

    So what if you tried to open file, which doesn't exist inside folder which doesn't exist?

    Something like:
    --open file
    local file = io.open( "|D|mydir/myfile.txt", "w" )
    --store something
    file:write( "something" )
    --close file
    io.close( file )
    I'm not at my PC right, so can't try it. Just an Idea :D
  • As a thought - if you can't create folders, perhaps you could come up with some naming convention that you can parse and filter like folders,

    e.g. If you want a folder called "saves" and inside it you want to create files tempa.dat, tempb.dat etc you'd just call the file saves_tempa.dat and saves_tempb.dat

    Just my $0.02
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • @ar2rsawseen - I just tried your idea - it return NIL file

    @techdojo - Right, I can do something like what you suggest. Basically do my own pseudo directory management and make sure the names are unique. I was just trying to avoid doing that...
Sign In or Register to comment.