On 05/18/11 13:48, Mark Mcvittie wrote:
> Thanks, that's what I was doing, double-clicking the app in
> test/help and it was returning the wrong working directory.

        No, sounds like you're assuming the current working directory
        is where the executable is, which is not the definition of the cwd.

        getcwd() is an operating system call that returns an attribute
        of the current process. It's very specific, inherited from one
        program to another, like an environment variable. Its value
        at a program's startup depends on the parent process that invoked it.
        In this case, that's the Finder, which probably always has the cwd
        set to the user's home dir.

        You can't make assumptions about what the cwd is set to.
        The cwd has one specific purpose: to define the directory
        from which relative filenames will be resolved.

        Note that in the unix shells, your cwd can be your home dir,
        yet you can run "/usr/local/bin/someapp" and when the process
        starts, the cwd will still be your home dir, and not /usr/local/bin.

        What you want isn't "the current working directory",
        you seem to want "the executable directory", which are two
        different things. See other posts for details on how to get that.

> Wouldn't it be better if fl_getcwd() could do this for us

        No, getting the cwd is a very specific thing, and getcwd/fl_getcwd
        are doing what they're supposed to.

        What you want would have to be called something else.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to