[interchange-cvs] interchange - racke modified code/UI_Tag/write_relative_file.coretag

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Nov 13 10:58:06 EST 2003


User:      racke
Date:      2003-11-13 15:58:06 GMT
Modified:  code/UI_Tag write_relative_file.coretag
Log:
let writefile handle the creation of the path
use the 5.0 method of file control

Revision  Changes    Path
1.4       +5 -11     interchange/code/UI_Tag/write_relative_file.coretag


rev 1.4, prev_rev 1.3
Index: write_relative_file.coretag
===================================================================
RCS file: /anon_cvs/repository/interchange/code/UI_Tag/write_relative_file.coretag,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- write_relative_file.coretag	2 Apr 2003 18:59:47 -0000	1.3
+++ write_relative_file.coretag	13 Nov 2003 15:58:06 -0000	1.4
@@ -4,8 +4,9 @@
 
 	[write-relative-file file=name]content[/write-relative-file]
 
-Writes a file C<name> in the catalog directory. C<name> must be relative; 
-it will return undef if the file name is absolute or contains C<..>.
+Writes a file C<name> in the catalog directory. C<name> is subject to
+file control (e.g. it must be relative), it will return undef if
+the check isn't passed.
 
 =cut
 
@@ -17,15 +18,8 @@
 sub {
 	my ($file, $data) = @_;
 #::logDebug("writing $file");
-	$file =~ m:(.*)/:;
-	return undef if Vend::File::absolute_or_relative($file);
-	my $dir = $1;
-	use File::Path;
-	if($dir and ! -d $dir) {
-		return undef if -e $dir;
-		File::Path::mkpath([$dir]);
-	}
-	Vend::Util::writefile(">$file", $data);
+	return undef unless Vend::File::allowed_file($file, 1);
+	Vend::File::writefile(">$file", $data, {auto_create_dir => 1});
 }
 EOR
 








More information about the interchange-cvs mailing list