[Clipart] Namespace conflicts on the filenames.

Jonadab the Unsightly One jonadab at bright.net
Fri Jan 7 06:14:19 PST 2005

"Jonadab the Unsightly One" <jonadab at bright.net> writes:

>>> How can we track what filenames have been used, across releases?
>>> A special directory of zero-size files perhaps?  Some other way?
> I think I like the idea of including some or all of the author's
> name.  That would at least prevent one person's submissions from
> trampling over another's.  But I think it would be better to have
> the title first...  hmm...
> What about title_author_yymmdd_nn.svg

That starts to get rather long, I fear.

Here is what I have now:

sub generate_filename {
  my ($m) = @_; # Must be an SVG::Metadata object, already filled out.
  my $maxlen = 27;
  # Older HFS filesystems (used by MacOS 8) can't handle more than 31
  # total, and we may be appending ".svg" or somesuch, so 31 - 4 = 27.

  my $t = lc $m->title();   $t =~ s/[^A-Za-z0-9.-]+/_/g;
  my $a = lc $m->author();  $a =~ s/[^A-Za-z0-9.-]+/_/g;

  while ($maxlen < length "${t}_${a}_00") {
    if (length $a) { $a =~ s/.$//; } # Abbreviate the author's name...
    else           { $t =~ s/.$//; } # and, if that's not enough, the title.

  my $n = "01"; # This way we get title_author_01.svg, title_author_02.svg, &c.
  my $name = ($a ? "${t}_${a}_$n" : "${t}_$n");
  while (-e catfile($CONFIG{destination_directory}, "$name.svg") or
         -e catfile($CONFIG{destination_directory}, "$name.rdf") or
         -e catfile($CONFIG{destination_directory}, "$name.zip") or
         -e catfile($CONFIG{destination_directory}, "$name.tar.gz")) {
    ++$n; $name = ($a ? "${t}_${a}_$n" : "${t}_$n");
  return $name;

As it stands, this ends up significantly truncating the author's name
in a number of cases.  For example, reasonable_title_jonadab_02.svg is
just exactly at the limit.

> Update:  a Google search reveals that MacOS 8 (or I think even MacOS
> 9 with a filesystem created originally under MacOS 8) has an even
> shorter limit, 31 characters.  That makes this issue even more
> pressing, since MacOS 8 is really not old enough that I want to tell
> its users to go away if we can avoid it.  As noted, I don't mind if
> StuffIt will truncate the names for them; can someone confirm it can
> do that?  Mark?  Andy?

Mark doesn't know, and I forgot that Andy is in Ecuador just now and
so not answering mail.  Anybody else know a Mac guru?  I'd like to
bump the limit up a bit from 31 characters and add in the date, but
only if it won't cause problems.

Oh, and I've also turned up another tidbit:  ISO9660 also has a
31-character limit, according to some sources.

split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/

More information about the clipart mailing list