The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_getbasepath
Owen Alanzo Hogarth
Guest

Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?
SDL_getbasepath
hardcoredaniel
Guest

Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location: /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_getbasepath
Owen Alanzo Hogarth
Guest

Thank you, using android  
Quote:
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);



worked out.


On Mon, Aug 17, 2015 at 8:25 PM, hardcoredaniel wrote:
Quote:
Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_getbasepath
Leonardo


Joined: 11 Feb 2010
Posts: 46
SDL_RW* functions also read from files in asset folder.


Em seg, 17 de ago de 2015 às 16:46, Owen Alanzo Hogarth escreveu:

Quote:
Thank you, using android  
Quote:
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);



worked out.



On Mon, Aug 17, 2015 at 8:25 PM, hardcoredaniel wrote:
Quote:
Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_getbasepath
Owen Alanzo Hogarth
Guest

@Leonardo

Do you have some sample code that you use with SDL_RW* functions? I would prefer to keep things inside of SDL_* functions if at all possible.


Best,
Owen


On Tue, Aug 18, 2015 at 3:48 AM, Leonardo Guilherme wrote:
Quote:
SDL_RW* functions also read from files in asset folder.


Em seg, 17 de ago de 2015 às 16:46, Owen Alanzo Hogarth escreveu:

Quote:
Thank you, using android  
Quote:
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);



worked out.



On Mon, Aug 17, 2015 at 8:25 PM, hardcoredaniel wrote:
Quote:
Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_getbasepath
Leonardo


Joined: 11 Feb 2010
Posts: 46
Well, you'd use SDL_RWFromFile("file"), and if there's a file in assets/ folder with that name, it will automagically open. Then you use it almost as you would with stdio. The wiki page might have more info, but its really a no brainer. Replace fopen/fclose/fread with SDL_RW* stuff and you're set.


It is worth noticing that all SDL functions that open files (like SDL_LoadBMP) use RWops by default, they should just work on android.


Here's the wiki link: https://wiki.libsdl.org/SDL_RWops


HTH,

Leonardo.


Em seg, 17 de ago de 2015 às 18:15, Owen Alanzo Hogarth escreveu:

Quote:
@Leonardo

Do you have some sample code that you use with SDL_RW* functions? I would prefer to keep things inside of SDL_* functions if at all possible.


Best,
Owen


On Tue, Aug 18, 2015 at 3:48 AM, Leonardo Guilherme wrote:
Quote:
SDL_RW* functions also read from files in asset folder.


Em seg, 17 de ago de 2015 às 16:46, Owen Alanzo Hogarth escreveu:

Quote:
Thank you, using android  
Quote:
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);



worked out.



On Mon, Aug 17, 2015 at 8:25 PM, hardcoredaniel wrote:
Quote:
Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_getbasepath
Jonny D


Joined: 12 Sep 2009
Posts: 932
Also, the satellite libraries (SDL_image, SDL_ttf, etc.) load files via SDL_RWops, so they work right on Android as well.

Jonny D




On Tue, Aug 18, 2015 at 1:34 AM, Leonardo Guilherme wrote:
Quote:
Well, you'd use SDL_RWFromFile("file"), and if there's a file in assets/ folder with that name, it will automagically open. Then you use it almost as you would with stdio. The wiki page might have more info, but its really a no brainer. Replace fopen/fclose/fread with SDL_RW* stuff and you're set.


It is worth noticing that all SDL functions that open files (like SDL_LoadBMP) use RWops by default, they should just work on android.


Here's the wiki link: https://wiki.libsdl.org/SDL_RWops


HTH,

Leonardo.


Em seg, 17 de ago de 2015 às 18:15, Owen Alanzo Hogarth escreveu:

Quote:
@Leonardo

Do you have some sample code that you use with SDL_RW* functions? I would prefer to keep things inside of SDL_* functions if at all possible.


Best,
Owen


On Tue, Aug 18, 2015 at 3:48 AM, Leonardo Guilherme wrote:
Quote:
SDL_RW* functions also read from files in asset folder.


Em seg, 17 de ago de 2015 às 16:46, Owen Alanzo Hogarth escreveu:

Quote:
Thank you, using android  
Quote:
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);



worked out.



On Mon, Aug 17, 2015 at 8:25 PM, hardcoredaniel wrote:
Quote:
Hi,

as far as I understand the concept, "assets" are read-only files that are bundled inside the app's a.pk - i.e. they are not unpacked and thus the assets do not form a "real" directory.

You can read assets in C via dedicated functions only, they cannot be accessed via direct file IO. I don't know whether SDL implements this "special" Android behaviour for assets. If not, you can take a look at this header file
Quote:
#include <android/asset_manager.h>in the Android NDK on how to open & read asset files.
Regards,

Daniel


---------- Původní zpráva ----------
Od: Owen Alanzo Hogarth
Komu:
Datum: 17. 8. 2015 14:05:54
Předmět: [SDL] SDL_getbasepath
Quote:
Hi it seems SDL_getBasePath() isn't implemented on android atmI found this doc: https://hg.libsdl.org/SDL/file/8d826bc39a45/src/filesystem/android/SDL_sysfilesystem.c#l46


so I implemented it myself but with this test application I am getting back this location:  /data/data/org.libsdl.app/files/


that doesn't seem to be the resources directory and even if i add an assets directory and put my files in there, they are not copied over to that location.


How can I get the location of the assets directory through SDL on android?




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org