Opening file by dragging onto an app causes crash

Problems building or running the engine, queries about how to use features etc.
User avatar
paddy
Greenskin
Posts: 136
Joined: Sun Aug 01, 2004 7:07 pm

Opening file by dragging onto an app causes crash

Post by paddy »

Hi

I am trying to associate a file extension with an ogre based program, so also when I drag a file over my app in win32 it will pass the arg to the program.

The only problem is that it seems ogre crashes when I try load() from the ConfigFile - it appears that all concepts of relative paths are lost.

If I change my file path from "resources.cfg" to a full path starting from "C:\..." that line works but I get another exception from the archive manager.


How do I preserve my app's ability to know its relative location and pass command line arguments?

I believe I am running the OGRE 0.15.0 [Hastur] release still.


Additional note: it also happens if I drag a file over an ogre demo program.
User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
x 2

Post by pjcast »

First of all... dragging a file over your exe is a little different than associating file types with your app. To associate file types with your exe you have to put an entry in the registry... or do it manually by going to explorere, tools -> folder options -> file types.

Sounds like windows is running your app from the location of whatever file you dragged over it... What you could do is set an entry in the Windows registry for your app's install location... Than when you app starts, change the current working directory. And then your app will find you config script.... and you can still use relative paths.

IIRC, the argument that you recieve in main when a file is dragged over is a full path/filename to the file to e opened... So that is no problem.

But I could be wrong... What is the other exception you were getting?
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/
User avatar
paddy
Greenskin
Posts: 136
Joined: Sun Aug 01, 2004 7:07 pm

Post by paddy »

Thank you for the quick response :)

The first exception is error #8, ConfigFile::load described as "'resource.cfg' file not found!" on line 48 of OgreConfigFile.cpp.


If I give that load() function an absolute path then I get:

Error #7, ArchiveManager::load described as "Cannot find an archive factory to deal with archive of type FileSystem"

Line 60 of OgreArchiveManager.cpp


The program is using file paths relative to the directory the exe is in for all resource management, and I am dragging files in the same directory over the application, so I don't think it is mismatching the working directory based on the argument file's parent directory.
I may be able to find the app's true path and set the working directory to it's parent using environment variables - if you think that may work best I'll try to look into that option.
I just found it odd that dragging a file in the same directory over the app would cause this behavior, and thought there may be a default setting in one of the ogre objects I missed.

Thanks again for the help, I'll keep working at it.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

You must make sure you give an absolute path to plugins.cfg as well, as it looks like the FileSystem plugin could not be loaded.