[Bf-committers] Native path handling for blender

Andrea Weikert andrea at aweikert.de
Thu Feb 23 14:19:15 CET 2006


Hello Guillaume,

first of all, your work is of course welcome, since I've been planning to
improve that area of Blender for a while too.

As you've seen, the code in that area is a bit messy, like different
implementations for almost the same stuff, etc.
The filename (and directory) handling deserves a much bigger rewrite. My plans
are to define a struct that
holds the dir, filename, volume (on win32 C: etc.) in separate members and
internally store the dir in POSIX form.
The rest of the Blender code then only needs two functions to retrieve the
actual filename in native format and to convert the native filename string to
the struct - similarly to the functions that you provided.
The only places where there should be code that actually deals with messing with
the filename strings should be hidden behind a nice API to be ussed by the rest
of Blender code. The only places where conversion would need to take place then
is when the user inputs a filename and when the filename is read to access a
file.
This place is also the only one where some switching between '/' and '\\' would
have to be done - in my view no problem to support this for Windows there.

This all needs a careful design, paying attention to which functions are needed
and how to name them accordingly. Right now many functions have expected side
effects that the rest of Blender sometimes relies on, which needs to be handled
correctly too. One thing that bothers me too for example is that often '/' is
passed as a default filename, on windows too, which leads to an incorrect path.

I will put up my preliminary design for this on the wiki within the next few
days, would be nice to get your feedback and your experience would be welcome
too, so maybe we could work on this together?

Thanks and greetings,

Andrea (nick elubie)

> ----- Original Message -----
> From: "Yomgui" <yomgui1 at gmail.com>
> To: <bf-committers at projects.blender.org>
> Sent: Thursday, February 23, 2006 1:21 PM
> Subject: Re: [Bf-committers] Native path handling for blender

> Hello,

> I've recoded blenlib/util.h. Now I'm working on src/filesel.c.
> Check given files (caution, it's not usable as it because you need to
> modify the rest of Blender and I've not tested if it compiles on
> Win/Unix).

> Some functions have been removed : duplicate features or not needed anymore.
> There is some confusion on Windows with '/' and '\', I don't know if
> all Windows API support both. I've seen that Blender code resolves
> that by switching them...
> But bring a support of both to users it's a nightmare to handle in Blender.
> A solution to keep the feature without complexify the code is to
> search where are all external paths input (like from UI, from an
> external lib or from a file), then put a switch at this level only to
> be sure that all paths are really native and supported internally. So,
> internal code will be more simple because we've made an assumption on
> how paths are written.

> This work is very interesting because I've already removed many of
> buffer overflow ;-)



More information about the Bf-committers mailing list