Game Development Community

Filehandling and pathing problems

by Sean OBrien · in Technical Issues · 07/07/2006 (1:41 am) · 1 replies

Ok, so all the demos and such are great fun but I hit a major (i.e. fatal) stumbling block when attempting to incorporate new scriptfiles, check on the existence of other files (e.g. config files, player profiles, etc), or generally do anything that would be a snap in a normal language.

I threw together this quick example to illustrate:

// Can't figure out how to access the filesystem
//

enablewinConsole(TRUE);

setLogMode(6);

// Some comments indicate that nothing works if this isn't set??
Setmodpaths("common");


// Try some really basic concepts
//
Warn("I'm getting really tired of not having any filehandling.\n");

Echo("Tilde path expansion...");
echo("   ExpandFilename(\"~/demo.cs\") ==> " @ expandfilename("~/demo.cs"));
echo("...doesn't expand?\n");

echo("Dot path expansion...");
echo("   ExpandFilename(\"./demo.cs\") ==> " @ expandfilename("./demo.cs"));
echo("...doesn't expand either?\n");

Echo("and not using any path manipulation at all...");
echo("   ExpandFilename(\"/demo.cs\") ==> " @ Expandfilename("/demo.cs"));
echo("   ExpandFilename(\"demo.cs\") ==> " @ Expandfilename("demo.cs"));
echo("...doesn't work.\n");

echo("worst of all, even using several variations:");
echo("   IsFile(\"main.cs\") ==> " @ isFile("main.cs"));
echo("   IsFile(\"/main.cs\") ==> " @ isFile("/main.cs"));
echo("   IsFile(\"./main.cs\") ==> " @ isFile("./main.cs"));
echo("THIS FILE ITSELF doesn't exist apparently?\n");

and the results were like so:

I'm getting really tired of not having any filehandling.

Tilde path expansion...
   ExpandFilename("~/demo.cs") ==> ~/demo.cs
...doesn't expand?

Dot path expansion...
   ExpandFilename("./demo.cs") ==> ./demo.cs
...doesn't expand either?

and not using any path manipulation at all...
   ExpandFilename("/demo.cs") ==> /demo.cs
   ExpandFilename("demo.cs") ==> demo.cs
...doesn't work.

worst of all, even using several variations:
   IsFile("main.cs") ==> 0
   IsFile("/main.cs") ==> 0
   IsFile("./main.cs") ==> 0
THIS FILE ITSELF doesn't exist apparently?

onExit: Unknown command.

Obviously I didn't define OnStart() and OnExit(), etc. but that's not the issue.

So here's the question: How do I determine whether or not the file "abc.xyz" exists in the root folder? In a different folder altogether?

Thanks, Khorfax.

#1
07/18/2006 (8:19 am)
Here is a a related thread to get you started, search the site for similar issues before making new posts