File access API?

About Monkey 2 Forums Monkey 2 Development File access API?

This topic contains 6 replies, has 4 voices, and was last updated by  Diffrenzy 1 year, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11758

    PhatPeter
    Participant

    Anyone made a file access Monkey2 extension for iOS and Android? I for one need to save me some time so would happily pay good money for one here and now.

    #11763

    scurty
    Participant

    Do you mean to make Files and Directories on Mobile? Or stuff like CHMOD? Or attrib +s +a?
    I haven’t tested LoadString("..") on a mobile device myself yet but it should work just fine.
    If for some reason not, maybe look into Local MyDataBuff := DataBuffer.Load("file path") then use MyDataBuff.PokeString and MyDataBuff.PeekStringto write/read the data to the Buffer. And called MyDataBuff.Save("file path")
    iOS and Android file paths should follow the POSIX’y file system hierarchy so “/tmp” or “/bin” is the in root directory.
    For Windows the root directory is “C:/”

    For file attributes/permissions you’d need to impliment chmod() or _chmod in the libc.monkey2 module.

    #11771

    nerobot
    Participant

    LoadString based on DataBuffer.Load 😉

    Look at std.filesystem functions. There is an InternalDir() for example. Maybe it’s what you need.

    I can’t insert link to docs page because docs is dynamically showing by JavaScript, therefore I insert link to source code:

    github page

    #11779

    PhatPeter
    Participant

    That looks amazingly promising ! Thanks  yes exactly I mean creating files and reading them back for instance.

    I don’t have my Android with me to try things so I have to guess a bit, could anyone give an example how
    to save a png onto the external memory card or something similar?

    #11784

    scurty
    Participant

    Didn’t know it was based on DataBuffer. xD Interesting.
    Go Monkey!

    On Android I think an SD card is under a mounted device file. Since it’s based on the Linux Kernel it should be something
    like “/mnt/sdcard” mounted from “/dev/sdb” or “dev/sda”
    Saving PNG’s is simple using Pixmap.SetPixel and Pixmap.Save

    Edit: Or if you already have a loaded image, you can just use CopyFile

    #11794

    nerobot
    Participant

    Topic about image saving: http://monkeycoder.co.nz/forums/topic/how-to-save-a-image/

    There is also ExternalDir() function along with InternalDir.

    I’m not sure is it sdcard dir or not.

    But if it’s so, you can use something like this:

    #11823

    Diffrenzy
    Keymaster

    I’ve noticed that http://monkeycoder.co.nz/forums/topic/a-simple-applet-framework/ uses SDL_GetPrefPath to find a place for settings.

    I think Mark put it in the develop version of MX2

    I’m planing to use that for my savegames, and precomputations, across platforms.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.