Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Big Problem with Tier2 getcwd

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 29th Aug 2011 12:50
On Windows, AppGameKit is setting the default cwd to My Documents/AGK + program name

I can understand the reason for this as AppGameKit commands like readfile + writefile have to read/write data from there.

But I am using the fmod library for music handling and getcwd returns My Documents/AGK + program name not the real cwd.

I have no way to load music in fmod either than hardcoding the path, which I wouldn't know since the game could be installed anywhere.

This way of doing things has cut out the advantage of using tier2, as there is no possibility to using 3rd party libraries.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 29th Aug 2011 19:14 Edited at: 29th Aug 2011 19:19
In iOS the problem is worst as I cannot type in a hardcoded path + filename
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 29th Aug 2011 20:24
I didn't test any of this path stuff yet, but for Windows, you can retrieve the user's MyDocuments using the API:

WCHAR path[MAX_PATH];
HRESULT hr = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL,
SHGFP_TYPE_CURRENT, path);

But, I don't think it is the right approach. Normally, mobile devices works with the sandbox concept, which the application can have access to its own space + specific shared spaces, like photos, etc...

At first, AppGameKit should have a "AppStoragePath", "ApplicationPath", "SharedPath" (I made up the names), and any AppGameKit application should only use those and, if needed, add relative paths to them.

For example, flash & actionscript uses the following:

File.applicationStorageDirectory—a storage directory unique to each installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory

Of course, some of them are not applicable for all platforms. In any case, we shouldn't use absolute paths, ever.

Cheers

Paulo
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 29th Aug 2011 20:29
Well, after checking the docs (which I should've done before posting), I found AppGameKit has the GetWritePath function that returns the correct place where the application can write its own files.

So, I believe (still, I didn't test yet), you should get the write path calling the GetWritePath function, and only use it for all your files.

Can you check if it returns the proper path for you use in the fmod library?

Cheers

Paulo
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 29th Aug 2011 21:13
Data files (in this case music) are in the MEDIA folder (another useless limitation) and not in My Documents/AGK

I can understand that ON MOBILE systems one can only WRITE data to the app data folder. But one has to be able to read data files from ProgDir.

On desktops (windows/mac) this LIMITATION is unjustified.

AGK has just rendered the possibility to use 3rd party libs almost to zero. As things are right now, FMOD is unusable as I cannot load music from ProgDir.

Unless TGC changes this limitation, I am stuck, and can't move on with my project.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 29th Aug 2011 21:15
Quote: "Well, after checking the docs (which I should've done before posting), I found AppGameKit has the GetWritePath function that returns the correct place where the application can write its own files."


I just want to READ an MP3 file from PROGDIR (or PROGDIR/MEDIA right now) not write data!
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 29th Aug 2011 22:02
Well, in theory the same concept applies (write or read, the path that matters). However, I couldn't get GetWritePath() returning anything on my Windows test (using Basic). Is it Bug, TGC?

Can't you pass just the relative path, without having to actually call the getcwd() ? Like "media/yourfile.mp3". This is working for me, but of course I'm not using the same library as you.


Cheers

----------
Paulo
http://www.mobilecreators.com
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Aug 2011 09:17
Quote: "Can't you pass just the relative path, without having to actually call the getcwd() ? Like "media/yourfile.mp3". This is working for me, but of course I'm not using the same library as you."



Obviously media/music.mp3 works with the LoadMusic command, but I am using FMOD to load media/music.mp3 and this does not work, as AppGameKit is blocking all access to ProgDir and setting cwd to My Documents/AGC

I would like to know if this is going to be changed any soon, or if I just wasted 2 weeks of work and have to dump AGC
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Aug 2011 15:09
GetWritePath() is fixed for the next update and will return the write directory path from MyDocuments.

AGK will not stop you doing anything to the working directory, such as SetCurrentDirectory() and on Windows you can get the current exe location using

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Aug 2011 17:35
Paul

Got it working on Windows!!!

But I doubt that GetModuleFileName() exists on Mac & iOS.

Any suggestions how I can read files from media dir or progdir?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Aug 2011 19:03
On Mac and iOS you can use

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Aug 2011 19:34


Will test this out asap
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Aug 2011 21:49
Works GREAT!
The only little thing I came across is that in Windows i get the actual ProdDir, but in iOS I get the path to the MEDIA folder.

Is this how it's working, or am I doing something wrong?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Aug 2011 22:12
That's correct, on Mac and iOS you access the resources folder, on Windows we originally copied the idea and made a "media" folder that held resources for Windows, but in future media will be accesed from the root directory on Windows.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Aug 2011 22:25
OK great.
Thanks for the great help. I was almost going to give up on AGC, but now I'm back in track to work on my project!

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 21st Nov 2011 16:32
How do I get the exe location on Android?

I only came across this code, but unfortunately it's in Java so it will not do

String PATH = getFilesDir().getAbsolutePath();

Login to post a reply

Server time is: 2024-11-22 15:42:46
Your offset time is: 2024-11-22 15:42:46