Revision: 1397
Author: [email protected]
Date: Fri Nov 19 03:58:32 2010
Log: Avoid nytprofhtml failure due to over-long filenames RT#62319
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1397

Modified:
 /trunk/lib/Devel/NYTProf/Reader.pm

=======================================
--- /trunk/lib/Devel/NYTProf/Reader.pm  Tue Nov  9 14:58:56 2010
+++ /trunk/lib/Devel/NYTProf/Reader.pm  Fri Nov 19 03:58:32 2010
@@ -174,7 +174,19 @@
     confess "No fileinfo" unless $fi;
     $level ||= $self->current_level;

-    my $fname = html_safe_filename($fi->filename_without_inc);
+    my $fname = $fi->filename_without_inc;
+
+    # We want to have descriptive and unambiguous filename
+    # but we don't want to risk failure due to filenames being longer
+    # than MAXPATH (including the length of whatever dir we're writing
+    # the report files into). So we truncate to the last component if
+    # the filenames seems 'dangerously long'. XXX be smarter about this.
+ # This is safe from ambiguity because we add the fid to the filename below.
+    my $max_len = $ENV{NYTPROF_FNAME_TRIM} || 50;
+    $fname =~ s!/.*/!/.../! if length($fname) > $max_len; # remove dir path
+    $fname = "TOOLONG"      if length($fname) > $max_len; # just in case
+
+    $fname = html_safe_filename($fname);
     $fname .= "-".$fi->fid; # to ensure uniqueness and for info
     $fname .= "-$level" if $level;

--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [email protected]

Reply via email to