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 / POSSIBLE BUG : SetFolder( str ) not working?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Dec 2015 09:58
Hello everybody.

I had noticed a possible bug regarding SetFolder( str ) command.
I'm trying to make a program that read the content of specific folders on Windows.
So I called SetFolder( str ) command to set the 'read' folder to a specific path.
However, when I called GetReadPath() to check the new read path, it still didn't show the intended new path.
Instead, it shows the defaut read path which is inside the project folder.

I tried to remedy this by calling the SetRawWritePath ().
It does set the 'write' folder to the intended path, but unfortunately AppGameKit did not read the content of a 'write' folder.
So I still unable to read the content of a folder I want no matter what command I used.

Is this a bug? Or SetFolder( str ) was not intended to be able to read folders outside of the project folder?
I'm 100% sure the code is not the cause of this weird behaviour.
I thought the limitation of read and write only applied for mobile?

It would be great if SetFolder( str ) can really set its path freely, like SetRawWritePath ().

Here's the code, just in case.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 29th Dec 2015 12:14 Edited at: 29th Dec 2015 12:19
try print last error
GetErrorOccurred ()
GetLastError ()
SetErrorMode ( mode )
i guess it belongs file access permissions / sandbox mode.

SetFolder
Quote: "This command returns 1 on success or 0"

http://www.appgamekit.com/documentation/Reference/File/SetFolder.htm
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Dec 2015 13:06
Setfolder(folderpath$) returned 0

GetLastError() returned 'Invalid path for SetCurrentDir, must be relative path'
(i suppose Setfolder is the new version of the outdated SetCurrentDir)

Why did 'write' has it own 'raw' (SetRawWritePath ()) command for windows, while 'read' command did not?
Why enable writing to outside folder, but restrict reading of outside folder?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Dec 2015 14:43
Quote: "Why did 'write' has it own 'raw' (SetRawWritePath ()) command for windows, while 'read' command did not?
Why enable writing to outside folder, but restrict reading of outside folder?"


Opening files, writing files etc is always relative. So once you have SetRawWritePath, all reading will be from the same folder.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Dec 2015 15:53
That is exactly what I thought too, at least at the beginning.
I thought by using SetRawWritePath,, I can read and write on the path that I specify.

But it turns out SetRawWritePath only set the destination for the newly created files to be wrote on.
It turns out we cannot read files in folder specified by SetRawWritePath.
The error 'Invalid path for SetCurrentDir, must be relative path' occurs with both SetRawWritePath and SetFolder, no matter if they are both used at the same time, or only one is used
That is what I meant by possible bug.

No matter which command I use, I cannot set the 'read' path outside the project folder.
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 29th Dec 2015 16:51 Edited at: 29th Dec 2015 16:52
Quote: "No matter which command I use, I cannot set the 'read' path outside the project folder."

In my experience this is true even for writing. It generally goes to the apps media directory which is usually in your C:\Users\[user]\AppData ( a hidden directory in Windows 7 that you have to explicitly type the path to get to) directory somewhere. I suppose this is for security reasons? In any case I use Tier 2 so I can get around that using native methods in C++. That most likely doesn't help, but I thought I would share
-mrradd-
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Dec 2015 16:59
SetRawWritePath actually *can* set the 'write' path to outside of project folder.
But it seems that SetRawWritePath doesnt set the 'read' path along with it, when it's called
So we are left with 'write' folder outside the project folder, while the 'read' path remains inside the project folder.

I can't see any reason for this restriction on WIndows

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 30th Dec 2015 09:02 Edited at: 8th Jan 2016 08:13
Quote: "I can't see any reason for this restriction on WIndows"

I suspect this will be a condition imposed by the likes of Steam. They don't want a product that could be used for malicious purposes on their store, and being able to read/write to any folder (including System folders) would certainly give malicious users that ability. Of course, if you really need this functionality, you could move over to Tier2 and use regular C++ read/write functions which makes it a fairly pointless restriction right?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 3rd Jan 2016 12:26 Edited at: 3rd Jan 2016 16:45
Welp, I guess back to Darkbasic PRO for me.
Small people like me can't afford to learn C++ from scratch. I took a 1 month unpaid leave to work on this, but I guess I can't move the project to AppGameKit yet.

In DBPRO, the system will prevent writing/reading to system folders, no matter what.
And since AppGameKit permits 'writing' to outside folders, it might as well let the user 'read' it.
The ability to 'write' is already a risk of its own, might as well allow the 'reading'
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Jan 2016 15:54
When you ask AppGameKit to read a file it first checks the "write" folder. If the file is not found then it checks the "read" folder, which is always the app's media folder, and is read only. The SetFolder command sets an additional relative path to both of these locations. For example

Read Path = "C:\Program Files\My AppGameKit App\"
Write Path = "C:\Some Custom Folder\"

SetFolder( "/images/background" ) // always use forward slashes here to be cross platform compatible
LoadImage( "image1.png" )

will look in the following locations

C:\Some Custom Folder\images\background\image1.png
then
C:\Program Files\My AppGameKit App\images\background\image1.png
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 6th Jan 2016 21:49 Edited at: 6th Jan 2016 21:51
I tried to read the content of a folder outside of the project folder, which is on my desktop.

Thus, I called SetRawWritePath("C:\Users\Asus\Desktop\Neon") (and i tried forward-slashing it too SetFolder("C:\Users\Asus\Desktop\Neon"))

And then, I called GetFirstFile() and GetNextFile() commands to make a list for contents in that folder.

According to the decription, AppGameKit will first look in the 'write' folder i specified. and if the file is not found then it checks the "read" folder.
However GetFirstFile() and Getfolder() still returns informations about files in 'media' folder which is in the project file, instead of the 'Neon' folder on the desktop,

Why did this happened? I thought AppGameKit will look in the 'write' folder that I specify using SetRawWritePath("") first?
Why is that GetFirstFile() and GetNextFile() did not look in the folder I specify using SetRawWritePath("") ?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Jan 2016 00:43
The GetFirstFile and GetFirstFolder commands collate results from both the read and write folder into a single list. In this case the read folder is done first and then the write folder results will follow after. Duplicate file and folder names will only appear once in the list.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 7th Jan 2016 09:27
But why is it that the files in the folder that was specified using SetRawWritePath("") does not appear in the list?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Jan 2016 20:17
Just tested it and it works here, I used

although I was incorrect about the ordering in my previous post, the write folder is listed first and then the read folder.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 8th Jan 2016 08:09 Edited at: 8th Jan 2016 08:13
Thank you tremendously Paul for your attention and patience on this. Even I almost give up on this

I see, we had to call the SetFolder("") with an empty string for the other commands to 'read' from the 'write' file.
Otherwise, the other commands will just read from the project file (more precisely, the media file)

I would never have figured that out. Maybe we should include this instruction in the Help file to avoid confusions.

Also, is there any method to disable reading from the project file?
If only 1 folder scanned, then maybe ~5 files in the project file can be excluded after their info is registered in array with some workaround.
But, If we're reading ~500,000 files in a hard drive, those 5 files is a heavy burden on processing power and memory because their reading will repeat for every time the SetRawWritePath("E:\Temp") is called .

It would be great if we can set it so commands like GetFirstFolder() and GetNextFolder() only scan the folder specified only, like in DBPro.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jan 2016 08:45
Quote: "I see, we had to call the SetFolder("") with an empty string for the other commands to 'read' from the 'write' file."

If that is true, then this would be a bug? My Read path is very rarely the default folder, and I would not want to set and reset the folder each time to read from a raw folder path, and then perform a second read from a non-default read folder, to collate the results.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 8th Jan 2016 16:51
Quote: " is there any method to disable reading from the project file? "

Currently no, but I'll consider adding it

Quote: "If that is true, then this would be a bug?"

More like an unfortunate side affect. By default the folder is set with SetFolder("/media") when the app starts running, so in this case GetFirstFolder() would be looking in E:\Temp\media. If you are using other load commands then you can work around this by forcing the path to root by using LoadImage("/myimage.png") which will ignore the SetFolder part of the path. Or LoadImage("/media/myimage.png") to load it from the media folder whilst SetFolder is set to the empty string.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 8th Jan 2016 17:04 Edited at: 8th Jan 2016 17:06
Thanks guys . Finally after months of confusion on my part.

Now this is unrelated but since we're here, can I clarify something?
Is there really a bone limit (40) for 3D models with bone/limbs?
If there is, is there any plan to remove/increase the bone limit in the future?

I cannot find anything about bone limit in the help files.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 8th Jan 2016 17:14 Edited at: 8th Jan 2016 17:14
I added the 40 bone limit to comply with the OpenGL 2.0 spec which says there is a limit on the number of variables that can be passed to a shader. However devices are allowed to exceed the spec and provide space for more variables, so we'll have to do some testing to see what is common in the wild and then decide how to handle this gracefully.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 8th Jan 2016 22:12
I see. With current advancement of mobile device hardware, I think there are good chance that we can afford to exceed the limit.

Thank you everybody. Keep up the good work.

Login to post a reply

Server time is: 2024-11-17 02:49:40
Your offset time is: 2024-11-17 02:49:40