Crystal Space
Welcome, Guest. Please login or register.
July 25, 2014, 06:15:58 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8229 Members
Latest Member: Kula999lidia
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  vfs question
« previous next »
Pages: [1] Print
Author Topic: vfs question  (Read 1656 times)
mirkril
Newbie
*
Posts: 3


View Profile
« on: August 26, 2006, 07:00:56 pm »

I'm trying to load an image using the real path and filename of the file.
I'm using wxFileDialog to get the filename and path, I'm using
iLoader::LoadImage to load the image. The error I'm getting is
the file does not exist on VFS. I looked at viewmesh's source code
to get the basic outline of code.

Here's is the code I'm using:

wxFileDialog dialog(this, caption, default_dir, default_filename, wildcard, wxOPEN | wxFILE_MUST_EXIST);
if(dialog.ShowModal() == wxID_OK)
{
vfs->Mount("/tmp/avocado", dialog.GetDirectory().c_str());
vfs->ChDir("/tmp/avocado");
vfs->PushDir();

csRef<iImage> hm_img = loader->LoadImage(dialog.GetFilename().c_str(), CS_IMGFMT_TRUECOLOR);
if(hm_img == 0)
{
// error handling
}

// do stuff with image

vfs->PopDir();
hm_img = 0;

}

CS version: svn as of aug 25, 2006
OS: linux

Thanks for any help,
Jonathan
Logged
Commander
Newbie
*
Posts: 15


View Profile
« Reply #1 on: August 26, 2006, 09:04:09 pm »

I don't know if that's all, but try calling PushDir() before ChDir().

Good luck!
Logged
mirkril
Newbie
*
Posts: 3


View Profile
« Reply #2 on: August 27, 2006, 01:14:44 am »

Yup, that's a bug. Thanks for pointing it out.

I solved the original problem. I needed to end both the vfs path and the real path
with a file path separator, and the directory that wxFileDialog returns does not end with
a file path separator.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.191 seconds with 16 queries.