[Rd] basename returns "." not in filename (PR#13958)

Simon Urbanek simon.urbanek at r-project.org
Fri Sep 18 21:30:42 CEST 2009


Jens,

On Sep 18, 2009, at 15:08 , Jens Oehlschlägel wrote:

> Mmh,
>
>>> Point is, I gather, that trailing slashes are removed, e.g.,
>>>
>>> viggo:~/>basename foo/
>>> foo
>>>
>>> So, not a bug.
>
> This unfortunately means that we cannot distinguish between
> 1) a path with a filename
> 2) a path without a filename
>

Of course you can - but that's unrelated to the bug report.


> For example in the next version of the ff-package we allow a user to  
> specify a 'pattern' for all files of a ff dataframe which is path  
> together with a fileprefix, the above means we cannot specify an  
> empty prefix "" for the current working directory, because
>
>> dirname("./.")
> [1] "."
>> basename("./.")
> [1] "."
>> dirname("./")
> [1] "."
>> basename("./")
> [1] "."
>

I don't see the connection - I would suggest you read the IEEE Std  
1003.1-2001 which defines the behavior of basename (and the R  
documentation for basename clearly states the behavior as well).  The  
fact that you are trying to use the wrong tool for your purpose  
doesn't mean that the tool is broken. I would advise you to ask on R- 
help how to implement your pattern specification (just FWIW it's non- 
standard and requirement of trailing slashes does lead to very nasty  
problems for the user).

Cheers,
Simon



More information about the R-devel mailing list