Game Development Community

Problem writing to files

by Richard Andersson · in Torque Game Builder · 09/06/2007 (8:19 am) · 3 replies

I'm reposting this here since I think the trial forum isn't frequented by employees.

Well, as the topic says, is the FileObject::openForWrite functionanlity disabled in the trialversion? Are there any differences between the trial binaries and the purchased ones?

Reason I am asking is that I am unable to get the openForWrite function to actually open/create any file. It just returns 0 no matter what I try. I noticed that openForRead only seems to work under the /game directory, but openForWrite just wont work at all.

I have a version of TGE and the same technique works fine there.


I hope/assume it is ok to post script code here since it is part of the trial?

%fileName = "game/maps/test.map";
%fileHandle = new FileObject();
if(%fileHandle.openForWrite(%fileName))
{
   echo("success opening file for write");
      
   %fileHandle.writeLine("yey...");
}
else
{
   error("Unable to open file (" @ %fileName @ ") for write!");
}
%fileHandle.close();
%fileHandle.delete();


Suggestions appreciated.


EDIT:

I also get this in the log when shutting down TGB:

XML::beginWrite - Failed to write to filecommon/commonConfig.xml.
saveGameConfigurationData - Failed to write to file: common/commonConfig.xml

That function I haven't touched, but I guess it's the same problem...?

My guess is that something is preventing my game from writing to its game directory (or any directory) but I have no clue what.

#1
09/10/2007 (10:21 am)
Currently in 1.5.1 there is an error in the File IO for writing... you need to put a full path instead of a relative path, this should be fixed in future releases though :)
#2
10/21/2007 (1:58 pm)
Hi Matthew,
I was wondering if you have any suggestion for a work around this problem. Is there any function that will get me a full path to the .exe dir that I can use to plug into the open/write functions?
If not , when do you estimate the next release will be? I'm almost done with my game but without being able to load/save file I won't be able to release it.
Thanks,
Eyal.
#3
12/06/2007 (9:23 am)
I found an work around by Isaac Barbosa.
http://www.garagegames.com/mg/forums/result.thread.php?qt=67663
Eyal.