views:

119

answers:

1

Hello everybody,

When I open a source file from my project and I run a custom build script, I want the working directory to initialise to the actual current working directory from which the source file was opened. Any idea how to do this?

UPDATE: Also, how can I set the "Working Directory" to one level above the actual working directory?

A: 

I'm not sure I understand exactly what you're after, but there are a number of variables that can be used in External launch configurations.

From your description, the likely one is to put ${resource_loc} in the Working Directory: field.

From the description:

Returns the absolute file system path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.

Alternatively, ${container_loc} might be more appropriate if you need to run on a directory:

Returns the absolute file system path of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.

Rich Seller
This is correct. When I try the ${container_loc} variable it seems to work the first time when I compile but the second time, I encounter a problem: 'Variable references empty selection'.
cmdev
It's very interesting :) I found that if the focus is changed from the source file to another pane inside Eclipse, then ${container_loc} variable becomes empty. So that means that it's changes values depending on which tab is open.
cmdev
The ${resource_loc} will not do the trick because it contains the path with the actual file, and not just the directory of the file. The ${resource_loc} gives the correct path of the file.
cmdev
Under Window->Preferences->run\Debug->Launching->Launch Operation, you can select the option "Always launch the previously launched application", for internal launches this makes rerunning (e.g. with F11) run the same build, it *may* work for external launches too
Rich Seller