[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# and FilePath and Conscript_chdir 1

From: David Sanderson
Subject: # and FilePath and Conscript_chdir 1
Date: Thu, 25 Oct 2001 20:36:01 -0400

Let's suppose I want to get a path to a file from one of my Conscript
files for use in some auxiliary action it needs to take.  I tried the

    my $path = FilePath("#platform/program");

The resulting path was just the same, with the # stripped.  The problem
is that I have

    Conscript_chdir 1;

in my Construct file, so the relative pathname returned by FilePath does
not work relative to the directory that is current when cons executes my
Conscript file.

Now, that would not be so bad, if only there was an easy way for me to
discover what was the top directory of the sandbox.  But I have not
been able to find any.  I explored the cons code a little bit (revision
1.170 from CVS) and the closest I could come was $dir::top->{path} and
$dir::top->{srcpath}, which are initialized in dir::init(), but which
are simply ".", which is not what I need.

I know I can record the current directory in my Construct file and use
that in my Conscript file, but it seems rather awkward to have to do

There are any number of other solutions that involve changing cons:
have FilePath always return fully-qualified pathnames, for instance, or
provide an AbsoluteFilePath method that does that.  Or even just provide
a TopDir method (say) that returns the fully-qualified pathname of the
root of the sandbox.

So, I'm writing to ask, is there something I'm overlooking here?


David Sanderson (address@hidden)

P.S. It would be nice if FilePath did %-expansion, since when I gave it

    my $path = FilePath("#platform/program%SUFEXE");

the %SUFEXE came out unaltered.

P.P.S. It looks like cons sets $dir::top->{srcpath} but never uses it;
perhaps it's an artifact that can go away?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]