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 Studio Chat / GetFileCount() issue

Author
Message
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 17th Jan 2020 21:22 Edited at: 22nd Jan 2020 22:38
GetFileCount(1) won't return the total count of files of the write folder when creating new images through SaveImage() to the write folder, it only returns the correct count again after rebooting the app??

I thought GetFileCount() was supposed to be capable of returning the current files in a folder, but when I create a whole bunch of files using SaveImage it won't update to the new file count.

What am I doing wrong here?





This is put in a Repeat loop that continues for as long as the .scene is active. Creating any images works with pressing a virtualbutton. Saving the files my app creates works fine, they do exist and have generated names etc. Does SaveImage() fail to close the file somehow, until closing the app? Whatever the case, GetFileCount(1) won't return the correct amount of files now.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 17th Jan 2020 21:35
A slight update:

Using the OpenRawFolder() command and then using GetRawFolderNumFiles() does give me a realtime update of the file count. So I can use that as a workaround for now.
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 18th Jan 2020 00:24 Edited at: 18th Jan 2020 00:35
The results get cached internally. I believe SetFolder also tells the cache to refresh itself. Sounds like a bug that SaveImage does not.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Jan 2020 01:39
Yeah I think it's a bug too.

By the way SetFolder doesn't actively check for anything, so I'm not sure it resets anything. I once had a SetFolder("/media/cards") accidentally set within a loop, which did all kinds of crazy things, like creating dozens of new folders within folders hahaha.
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 18th Jan 2020 07:13
(Going by the Tier 2 code at github.)
SetFolder sets the m_bUpdateFileLists flag internally which is checked as soon as GetFileCount, GetFolderCount, GetFirstFolder, or GetFirstFile are called. When set, that folder and files are cached.

OpenRawFolder caches the folder when it's called and is a separate list.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Jan 2020 15:22 Edited at: 18th Jan 2020 15:23
Interesting, yeah that makes sense. I guess its more a case of SetFolder not caring about whether a folder exists then. Upon further inspection, SetFolder("") does not return to the regular Read path anymore either, but sticks with the Write path. I think something is broken when it comes to OpenRawFolder / SetFolder too.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Jan 2020 15:53 Edited at: 18th Jan 2020 16:42
Is anyone else working with the GetFolder() command? Because for some magical reason it won't return the path the second time it was used in my code. Right after closing a folder opened using OpenRawFolder and after using SetFolder("") to return to the root and read folder. I'm going insane lol, because now any images loading after this .scene can't be found, despite literally telling the program to return to the root directory again for the read folder (regular 'media').

edit: Okey, apparently SetFolder("") results in GetFolder() returning an empty string when in the Root folder. And another thing I found out is that to truly return to the root folder, you will have to use two separate calls of the SetFolder() function. You have to use SetFolder("") to return to the root and after that SetFolder("media") to return to the default read path. Doesn't solve the GetFileCount(1) issue of not updating.
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 19th Jan 2020 15:59
From the AppGameKit docs:
Quote: "There are two ways to return to the base path. The first is to call SetFolder("") using an empty string. The other is to precede your path with a forward slash, SetFolder("/stuff"). "


You should probably post some sample code so others can see what you're doing and how to help.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 21st Jan 2020 17:03
Thanks adambiser, but the problem I had with the folders was solved already.

In order to prevent AppGameKit Studio from creating new folders, I should not use a / in front of the folder name within a loop. And in order to return to the read folder, it has to be SetFolder("") and then another command SetFolder("media") to return to the actual default read folder. I was using SetFolder("/media") which created a media folder in the write folder, instead of returning to the default read folder. Mostly my bad I guess.

However, the bug with GetFileCount(1) still exists.

Login to post a reply

Server time is: 2024-04-19 11:42:07
Your offset time is: 2024-04-19 11:42:07