Thursday, September 11, 2003 11:36 PM Michael G Schwern <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 11, 2003 at 08:36:02PM +0300, Vladimir Lipskiy wrote: > > > Famous last words: "Our data is perfect, we don't need to check our > > inputs." > > > > Yes. Our data is perfect and we don't need to check our inputs if we > > play by rules. And the rules are: > > > > Always use concat_dirnames to concatenate directory names > > Always use append_filename to append a file name to a path > > Always keep in mind that this tool gives you a proper result > > when you give it proper input, which is simple directory > > names, simple file names, and paths produced by this tool only. > > If you observe the rules, you won't get into a mess. > > People make mistakes. Perhaps you should produce some errors if a user > strays outside these rules. Garbage in, garbage out: Bad. Garbage in, > error out: Good. It really does that. I mean that it returns a "" when it suspects its arguments to be wrong. > I'll admit to not knowing the general error philosophy of Parrot ops. It could throw an internal exception, but ... I am not convinced we should switch to that sort of indicating errors. Though what kind of errors it ought to provide is a subject to be arguing about. > > >What if the volumes don't match? > > > > Don't match against what? concat_dirnames doesn't do matching arguments > > against anything but PARROT_FS_DIRNAME_START and PARROT_FS_DIRNAME_END, > > which, for example, are '[' and ']' on VMS. > > What if I feed you: > > concat_dirnames("VOL1:[dir.dir]", "VOL2:[dir.dir]") > > Well, I suppose that's simple, its an error since you can't usefully > concatenate two absolute directories. Anyhow, the point is is an *error*. Yes, and since concat_dirnames() isn't supposed to concatenate anything but dirnames. > > > What if I'm adding a path with a volume to one without? > > > > Still. You get what you do. On Mac: > > > > concat_dirnames('my disk:a', ':b') = ':my disk:a:b' > > Mac's a special case since, IIRC, :b can either mean "The volume called b" > or "The file/directory in the current directory called b". No. Volumes can't start with a ":". The special case is that :b can mean either the file b or the directory b in the current directory. So Mac treats ":my disk:a:b" as Unix treats "my disk/a/b". > But I was unclear. I meant the other way around. > > concat_dirnames("b", ":my disk:a"); > > Trying to concatenate an absolute directory onto a relative one should > produce an error. What do you mean by "absolute directory"? > > File::Spec has an individual function for such purposes, catpath(). > > We can't process more than two in-arguments in PASM, so we would take > > advantage of prepend_volume and things of such sort. > > Unless I'm missing something, since the volumes and root dirs are already > attached to the filepath string, you don't need more than two arguments. And one doesn't need to concatenate such absolute paths unless he/she/it is a psycho. Moreover you just said yourself above that there was no use while conacatenating absolute paths and I agreed with you. Anyway I was speaking of Perl5 File::Spec function catdir() which actually takes three arguments: a volume, directory, and file. It has to be admitted, my patch ... /everyone rises in applause ________ (___( \_____ (___( (___( _____ (___(__ / | | |_| (~: BOO-O-O! May I go on? Good! ... STILL needs some reworking (sniff-sniff) to effectively resist naughty users. So I'll take a pause and lay out a new draft of the tool in the immediate future. And if the draft pleases everybody I'll go implement it.