]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Posting/Write.pm
modified version check
[selfforum.git] / selfforum-cgi / shared / Posting / Write.pm
index b7338f657a940b61ea0942612054a7d1c346361e..62fa11cb75aef9857a02719e061ee175a6445f94 100644 (file)
@@ -4,7 +4,7 @@ package Posting::Write;
 #                                                                              #
 # File:        shared/Posting/Write.pm                                         #
 #                                                                              #
 #                                                                              #
 # File:        shared/Posting/Write.pm                                         #
 #                                                                              #
-# Authors:     AndrĂ© Malo <nd@o3media.de>, 2001-04-08                          #
+# Authors:     AndrĂ© Malo <nd@o3media.de>                                      #
 #                                                                              #
 # Description: Save a posting                                                  #
 #                                                                              #
 #                                                                              #
 # Description: Save a posting                                                  #
 #                                                                              #
@@ -14,15 +14,11 @@ use strict;
 use vars qw(
   %error
   @EXPORT
 use vars qw(
   %error
   @EXPORT
-  $VERSION
 );
 
 use Encode::Plain; $Encode::Plain::utf8 = 1;
 use Encode::Posting;
 );
 
 use Encode::Plain; $Encode::Plain::utf8 = 1;
 use Encode::Posting;
-use Lock qw(
-  :WRITE
-  release_file
-);
+use Lock;
 use Posting::_lib qw(
   get_message_node
   get_message_header
 use Posting::_lib qw(
   get_message_node
   get_message_header
@@ -47,7 +43,11 @@ use XML::DOM;
 #
 # Version check
 #
 #
 # Version check
 #
-$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+# last modified:
+#    $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
 
 ################################################################################
 #
 
 ################################################################################
 #
@@ -126,7 +126,7 @@ sub write_new_thread ($) {
   );
 
   save_file ($param -> {forumFile}, $forum) or return $error{forumWrite};
   );
 
   save_file ($param -> {forumFile}, $forum) or return $error{forumWrite};
-  release_file ($param -> {messagePath}.$tid.'.xml');
+  new Lock ($param -> {messagePath}.$tid.'.xml') -> release;
   return (0, $thread, $mid, $tid);
 }
 
   return (0, $thread, $mid, $tid);
 }
 
@@ -145,25 +145,24 @@ sub write_reply_posting ($) {
   my $mid   = 'm'.($param -> {lastMessage} + 1);
   my $tid   = 't'.($param -> {thread});
 
   my $mid   = 'm'.($param -> {lastMessage} + 1);
   my $tid   = 't'.($param -> {thread});
 
-  my $tfile = $param -> {messagePath}.$tid.'.xml';
+  my $tfile = new Lock ($param -> {messagePath}.$tid.'.xml');
 
 
-  unless (write_lock_file ($tfile)) {
-    violent_unlock_file ($tfile);
+  unless ($tfile->lock(LH_EXCL)) {
     return $error{threadFile};
   }
 
   else {
     return $error{threadFile};
   }
 
   else {
-    my $xml = parse_xml_file ($tfile);
+    my $xml = parse_xml_file ($tfile->filename);
 
     unless ($xml) {
 
     unless ($xml) {
-      violent_unlock_file ($tfile) unless (write_unlock_file ($tfile));
+      $tfile -> unlock;
       return $error{threadFile};
     }
 
     my $mnode = get_message_node ($xml, $tid, 'm'.$param -> {parentMessage});
 
     unless (defined $mnode) {
       return $error{threadFile};
     }
 
     my $mnode = get_message_node ($xml, $tid, 'm'.$param -> {parentMessage});
 
     unless (defined $mnode) {
-      violent_unlock_file ($tfile) unless (write_unlock_file ($tfile));
+      $tfile -> unlock;
       return $error{noParent};
     }
 
       return $error{noParent};
     }
 
@@ -202,12 +201,12 @@ sub write_reply_posting ($) {
 
     # save thread file
     #
 
     # save thread file
     #
-    unless (save_file ($tfile, \($xml -> toString))) {
-      violent_unlock_file ($tfile) unless (write_unlock_file ($tfile));
+    unless (save_file ($tfile->filename, \($xml -> toString))) {
+      $tfile -> unlock;
       return $error{threadWrite};
     }
 
       return $error{threadWrite};
     }
 
-    violent_unlock_file ($tfile) unless (write_unlock_file ($tfile));
+    $tfile -> unlock;
 
     $thread = $xml;
 
 
     $thread = $xml;
 

patrick-canterino.de