working with subdirectories

Started by Sackboy, Sat 23/08/2014 21:29:54

Previous topic - Next topic

Sackboy

my basic question is whether it is possible to read/write files from/to different (sub)folders? let's say i have a structure like this:

compiled\data\text\
compiled\data\graphics\lowres\
compiled\data\graphics\highres\
compiled\data\other\

i know that i can use $SAVEGAMEDIR$ with the "file"-functions to achieve this but this doesn't work with the "dynamicsprite"-functions. i don't know whether i am missing something but things like:

Code: ags
File* output = output.Open("data/text/myfile.txt", eFileWrite);
or
DynamicSprite* sprite = DynamicSprite.CreateFromFile("data/graphics/lowres/myfile.png");


don't work. is there a way to access subfolders without using $SAVEGAMEDIR$? and is it possible to load graphics from subfolders at all?

thanks for your help!

Sackboy

Crimson Wizard

#1
Quote from the manual (File.Open article):
Quote
IMPORTANT: If you open the file for writing, then you can ONLY work with files in the game directory. You CANNOT use a path, so any filename with "\" or "/" in it will automatically be rejected, for security reasons.
I think that might rather be a mistake. Perhaps the intention was only to deny accessing files outside of game directory. But I can't tell for sure.

Regardless, I won't recommend you to create new files in game directory anyway, because that will fail on Windows Vista, 7 and 8 if game is installed on drive C and user does not have administrator rights. Only create/change files in $SAVEGAMEDIR$ or $APPDATADIR$.


As for reading sprites - it is possible. However, as stated in the manual, "Only BMP and PCX files can be loaded with this command."

Mandle

Quote from: Crimson Wizard on Sat 23/08/2014 22:01:00
Quote from the manual (File.Open article):
Quote
IMPORTANT: If you open the file for writing, then you can ONLY work with files in the game directory. You CANNOT use a path, so any filename with "\" or "/" in it will automatically be rejected, for security reasons.
I think that might rather be a mistake. Perhaps the intention was only to deny accessing files outside of game directory.

Thus launching the popular and challenging adventure game: "The Quest To Recover The Hard-Drive"

SMF spam blocked by CleanTalk