Platform::getWorkingDirectory problems
by Neil Marshall · in Torque Game Engine · 03/02/2006 (1:02 pm) · 3 replies
I'm trying to override the getWorkingDirectory function in winFileio.cc so that instead of actually getting the working directory, it uses one that is specified on the commandline at startup. I need to do this because the .cs scripts are not in the working directory as is normal with Torque programs.
My first attempt was to create a static string in platform.h that would store the directory and then I could add a setWorkingDirectory function which I could call from main.cc. Unfortunatly I keep getting linking errors every time which I don't know how to solve.
My second attempt was to put another getWorkingDirectory in platformWin32.h in an attempt to have that one called because I believe I can store a string in platformWin32.h. That didn't work either because it said the function already has a body.
So right now I'm kind of at a loss as to how to do this properly. Does anyone have any ideas?
My first attempt was to create a static string in platform.h that would store the directory and then I could add a setWorkingDirectory function which I could call from main.cc. Unfortunatly I keep getting linking errors every time which I don't know how to solve.
My second attempt was to put another getWorkingDirectory in platformWin32.h in an attempt to have that one called because I believe I can store a string in platformWin32.h. That didn't work either because it said the function already has a body.
So right now I'm kind of at a loss as to how to do this properly. Does anyone have any ideas?
Torque Owner Jeff White
in winFileio.cc
bool Platform::setWorkingDirectory(const char *cwd_buf) { return SetCurrentDirectoryA(cwd_buf); }Then call setWorkingDirectory() with the path you want to use in main.cc before GetWorkingDirectory is called by anthing else.
Both macCarbFileio.cc and x86UNIXFileio.cc will need their own versions for setWorkingDirectory if you want cross platform support.
-Jeff
p.s.
The following should probably work for both macCarbFileio.cc and x86UNIXFileio.cc
bool Platform::setWorkingDirectory(const char *cwd_buf) { return (chdir(cwd_buf) == 0); }