[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 29 Jan 2007 21:16:56 -0000


albertel		Mon Jan 29 16:16:56 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - support getting back a cleaned path too
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.830 loncom/lonnet/perl/lonnet.pm:1.831
--- loncom/lonnet/perl/lonnet.pm:1.830	Thu Jan 25 16:09:24 2007
+++ loncom/lonnet/perl/lonnet.pm	Mon Jan 29 16:16:55 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.830 2007/01/25 21:09:24 albertel Exp $
+# $Id: lonnet.pm,v 1.831 2007/01/29 21:16:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1451,15 +1451,17 @@
 }
 
 sub clean_filename {
-    my ($fname)=@_;
+    my ($fname,$args)=@_;
 # Replace Windows backslashes by forward slashes
     $fname=~s/\\/\//g;
-# Get rid of everything but the actual filename
-    $fname=~s/^.*\/([^\/]+)$/$1/;
+    if (!$args->{'keep_path'}) {
+        # Get rid of everything but the actual filename
+	$fname=~s/^.*\/([^\/]+)$/$1/;
+    }
 # Replace spaces by underscores
     $fname=~s/\s+/\_/g;
 # Replace all other weird characters by nothing
-    $fname=~s/[^\w\.\-]//g;
+    $fname=~s{[^/\w\.\-]}{}g;
 # Replace all .\d. sequences with _\d. so they no longer look like version
 # numbers
     $fname=~s/\.(\d+)(?=\.)/_$1/g;