Skip to main content.
home | support | download

Back to List Archive

Re: FileFilter '%p' does not give FULL path to

From: Bill Moseley <moseley(at)>
Date: Thu Oct 10 2002 - 20:44:10 GMT
At 12:01 PM 10/10/02 -0700, Greg Fenton wrote:
>--- Bill Moseley <> wrote:
>> At 04:47 PM 10/09/02 -0700, Greg Fenton wrote:
>> >
>> >I need the full path to the temporary file.
>> >'%p' gives "./as8f4y75"
>> That is the path to the temporary file (although that's doesn't look
>> like a temporary file generated by swish).
>This is not the FULL path as indicated by the docs.  It is a relative
>path.  The docs should reflect this.

I think where the docs say:

   %p   =  Full pathname to work file

I don't think I wrote that, but I assume "Full pathname" was meant as the
file name *including* the directory part, instead of just the basename (to
distinguish from %f).  It's always been dependent on the setting of the
temporary path which could be a relative path, plus there's no 100% way to
get the absolute path from root.

>The example that is given in the docs (FileFilter description) is:
>    %p = "/tmp/tmp.1234.mydoc.txt"
>but there is no mention of the fact that this is because TEMP is set.

Right it should be clearer that the above is just an example and that the
actual location is really a mystery.  Patches are always welcome for the docs.

BTW - It is mentioned in the Changes file:

"Temporary file locations

Swish-e now uses the environment variables TMPDIR, TMP, and TEMP (in that
order) to decide where to write temporary files. The configuration setting
of TmpDir will be used if none of the environment variables are set.
Swish-e uses the current directory otherwise; there is no default temporary

It's also listed in the SWISH-CONFIG file, but not clearly, under the
TMPDIR config option.

Why does your filter require the absolute path from root?  You aren't
changing directories in your filter, are you?

>> It's useful if your filter needs to know just the directory name. 
>> Not sure why a filter might need that, but it's there just in case.
>My point is that "./" is not very useful information.  I would think
>that the value of '%d' should be `pwd` instead of "./".  If someone
>ever wanted to use this value, then what good is "./" to them?  What
>good is "./foo" as a value for '%p'? 

./  says it's in the current directory.  It's a valid path.  Roy just
posted the other day about swish-e not working and it was because he forgot
./ so in that case it seems like it was very useful. ;)  How else are you
going to write the current directory without knowing the absolute path from

Can't use `pwd`, of course:

  Bad command or file name

Perl uses a trick to walk up the directory tree to find root.  I have one
ISP that has removed read perms from ~/.. and so that even fails.
Sometimes you know where you are, but have no clue where you are in
relation to anything else.  I think I remember that from my college days.

>IMO, under all circumstances %p should be the full absolute path to the
>temp file, %d should be the full absolute path to the parent dir of the
>temp file, and %f should be the basename of the temp file.  I don't
>believe that the current behaviour makes much sense (though I'd be
>happy to hear otherwise).

Ok, then if the current directory ./ is not a good choice pick one that is.
I needs to be available on all platforms.  Not /tmp, as that's not on every
platform.  Root, probably exists everywhere, but then how often can a
normal user write to the root directory?  Not $HOME, of course.  Seems like
the only choice is the current directory.

>BTW: the filter I am using creates its own temporary directory and
>chdir()'s to that, so "./as8f4y75" is not useful to it.  I will set
>TEMP and hopefully this resolves the issue.

Well there's the problem.  Why not write the filter so it writes to that
directory instead of chdir'ing?  It knows where the directory is its
creating, right?

There's no question the docs can be improved.  I don't really read them
that often, and even when I do they make reasonable sense to me.  That
doesn't mean that they make sense to everyone -- so like I always say,
Patches Welcome!


Bill Moseley
Received on Thu Oct 10 20:48:08 2002