Author: abock
Date: 2006-08-27 22:12:07 -0400 (Sun, 27 Aug 2006)
New Revision: 64456

Added:
   trunk/taglib-sharp/src/TagLib/ReadOnlyException.cs
Modified:
   trunk/taglib-sharp/ChangeLog
   trunk/taglib-sharp/src/Makefile.am
   trunk/taglib-sharp/src/TagLib/Asf/File.cs
   trunk/taglib-sharp/src/TagLib/File.cs
   trunk/taglib-sharp/src/TagLib/Flac/File.cs
   trunk/taglib-sharp/src/TagLib/Mpc/File.cs
   trunk/taglib-sharp/src/TagLib/Mpeg/File.cs
   trunk/taglib-sharp/src/TagLib/Mpeg4/AppleTag.cs
   trunk/taglib-sharp/src/TagLib/Mpeg4/File.cs
   trunk/taglib-sharp/src/TagLib/Ogg/File.cs
   trunk/taglib-sharp/src/TagLib/Ogg/Flac/File.cs
   trunk/taglib-sharp/src/TagLib/Ogg/Vorbis/File.cs
   trunk/taglib-sharp/src/TagLib/WavPack/File.cs
   trunk/taglib-sharp/taglib-sharp.csproj
Log:
2006-08-27  Aaron Bockover  <[EMAIL PROTECTED]>

    * src/TagLib/ReadOnlyException.cs: New exception

    * src/TagLib/File.cs:
    * src/TagLib/Mpc/File.cs:
    * src/TagLib/Mpeg/File.cs:
    * src/TagLib/WavPack/File.cs:
    * src/TagLib/Flac/File.cs:
    * src/TagLib/Asf/File.cs:
    * src/TagLib/Mpeg4/AppleTag.cs:
    * src/TagLib/Mpeg4/File.cs:
    * src/TagLib/Ogg/File.cs:
    * src/TagLib/Ogg/Vorbis/File.cs:
    * src/TagLib/Ogg/Flac/File.cs: Save is now void, throws exceptions
    when a problem has arisen instead of eventually returning false, masking
    the source of the problem

    * taglib-sharp.csproj:
    * src/Makefile.am: Updated



Modified: trunk/taglib-sharp/ChangeLog
===================================================================
--- trunk/taglib-sharp/ChangeLog        2006-08-27 23:43:19 UTC (rev 64455)
+++ trunk/taglib-sharp/ChangeLog        2006-08-28 02:12:07 UTC (rev 64456)
@@ -1,3 +1,24 @@
+2006-08-27  Aaron Bockover  <[EMAIL PROTECTED]>
+
+       * src/TagLib/ReadOnlyException.cs: New exception
+
+       * src/TagLib/File.cs:
+       * src/TagLib/Mpc/File.cs:
+       * src/TagLib/Mpeg/File.cs:
+       * src/TagLib/WavPack/File.cs:
+       * src/TagLib/Flac/File.cs:
+       * src/TagLib/Asf/File.cs:
+       * src/TagLib/Mpeg4/AppleTag.cs:
+       * src/TagLib/Mpeg4/File.cs:
+       * src/TagLib/Ogg/File.cs:
+       * src/TagLib/Ogg/Vorbis/File.cs:
+       * src/TagLib/Ogg/Flac/File.cs: Save is now void, throws exceptions
+       when a problem has arisen instead of eventually returning false, masking
+       the source of the problem
+
+       * taglib-sharp.csproj:
+       * src/Makefile.am: Updated
+
 2006-08-25  Aaron Bockover  <[EMAIL PROTECTED]>
 
        * examples/Makefile.am: Added Makefile.am, was missing from forge

Modified: trunk/taglib-sharp/src/Makefile.am
===================================================================
--- trunk/taglib-sharp/src/Makefile.am  2006-08-27 23:43:19 UTC (rev 64455)
+++ trunk/taglib-sharp/src/Makefile.am  2006-08-28 02:12:07 UTC (rev 64456)
@@ -91,7 +91,8 @@
    $(srcdir)/TagLib/File.cs                                        \
    $(srcdir)/TagLib/StringList.cs                                  \
    $(srcdir)/TagLib/SupportedMimeType.cs                           \
-   $(srcdir)/TagLib/UnsupportedFormatException.cs
+   $(srcdir)/TagLib/UnsupportedFormatException.cs                  \
+   $(srcdir)/TagLib/ReadOnlyException.cs
 
 taglib-sharp.snk: $(top_srcdir)/taglib-sharp.snk
        cp $(top_srcdir)/taglib-sharp.snk .

Modified: trunk/taglib-sharp/src/TagLib/Asf/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Asf/File.cs   2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Asf/File.cs   2006-08-28 02:12:07 UTC (rev 
64456)
@@ -58,20 +58,13 @@
       {
       }
       
-      public override bool Save ()
+      public override void Save ()
       {
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("Mpc.File.Save() -- File is read only.");
-            return false;
+         if(IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("Mpc.File.Save() -- File is read only.");
-            return false;
-         }
+         Mode = AccessMode.Write;
          
          HeaderObject header = new HeaderObject (this, 0);
          header.AddUniqueObject (asf_tag.ContentDescriptionObject);
@@ -80,7 +73,6 @@
          Insert (header.Render (), 0, header.OriginalSize);
          
          Mode = AccessMode.Closed;
-         return true;
       }
       
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/src/TagLib/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/File.cs       2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/File.cs       2006-08-28 02:12:07 UTC (rev 
64456)
@@ -107,7 +107,7 @@
       
       public abstract AudioProperties AudioProperties {get;}
       
-      public abstract bool Save ();
+      public abstract void Save ();
       
       public ByteVector ReadBlock (int length)
       {

Modified: trunk/taglib-sharp/src/TagLib/Flac/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Flac/File.cs  2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Flac/File.cs  2006-08-28 02:12:07 UTC (rev 
64456)
@@ -74,29 +74,17 @@
       {
       }
 
-
-
-
-      public override bool Save ()
+      public override void Save ()
       {
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("Flac.File.Save() - Cannot save to a read only 
file.");
-            return false;
+         if(IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("Flac.File.Save() - Cannot save to a read only 
file.");
-            return false;
-         }
-
-
+         Mode = AccessMode.Write;
+         
          long flac_data_begin;
          long flac_data_end;
          
-
          // Update ID3 tags
          if(id3v2_tag != null)
          {
@@ -214,7 +202,7 @@
                   padding.Resize ((int)(padding_length + 4));
                   
                   Insert (v + padding, next_page_offset, next_keep - 
next_page_offset);
-               System.Console.WriteLine ("OGG: " + (next_keep - 
next_page_offset) + " " + (v.Count + padding.Count));
+                  //System.Console.WriteLine ("OGG: " + (next_keep - 
next_page_offset) + " " + (v.Count + padding.Count));
                   
                   break;
                }
@@ -249,7 +237,6 @@
          }
 
          Mode = AccessMode.Closed;
-         return true;
       }
       
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/src/TagLib/Mpc/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Mpc/File.cs   2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Mpc/File.cs   2006-08-28 02:12:07 UTC (rev 
64456)
@@ -61,22 +61,14 @@
       {
       }
       
-      public override bool Save ()
+      public override void Save ()
       {
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("Mpc.File.Save() -- File is read only.");
-            return false;
+         if(IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("Mpc.File.Save() -- File is read only.");
-            return false;
-         }
-
-
+         Mode = AccessMode.Write;
+         
          // Update ID3v2 tag
          long id3v2_location = FindId3v2 ();
          int  id3v2_size     = 0;
@@ -156,7 +148,6 @@
             RemoveBlock (ape_location, ape_size);
 
          Mode = AccessMode.Closed;
-         return true;
       }
       
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/src/TagLib/Mpeg/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Mpeg/File.cs  2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Mpeg/File.cs  2006-08-28 02:12:07 UTC (rev 
64456)
@@ -68,31 +68,31 @@
       {
       }
 
-      public bool Save (TagTypes types, bool strip_others)
+      public void Save (TagTypes types, bool strip_others)
       {
-         if (types == TagTypes.NoTags && strip_others)
-            return Strip (TagTypes.AllTags);
+         if (types == TagTypes.NoTags && strip_others) {
+            if(!Strip (TagTypes.AllTags)) {
+                throw new ApplicationException("Could not strip tags");
+            }
+            
+            return;
+         }
 
-         if (id3v2_tag == null && id3v1_tag == null && ape_tag == null)
-         {
-            if (strip_others)
-               return Strip (TagTypes.AllTags);
-
-            return true;
+         if (id3v2_tag == null && id3v1_tag == null && ape_tag == null) {
+            if (strip_others) {
+               if(!Strip (TagTypes.AllTags)) {
+                throw new ApplicationException("Could not strip tags");
+               }
+            }
+            
+            return;
          }
          
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("Mpeg.File.Save() -- File is read only.");
-            return false;
+         if(IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("Mpeg.File.Save() -- File is read only.");
-            return false;
-         }
+         Mode = AccessMode.Write;
 
          // Create the tags if we've been asked to.  Copy the values from the 
tag that
          // does exist into the new tag.
@@ -162,17 +162,20 @@
             success = Strip (TagTypes.Ape, false) && success;
 
          Mode = AccessMode.Closed;
-         return success;
+         
+         if(!success) {
+            throw new ApplicationException("Cannot write tags");
+         }
       }
 
-      public bool Save (TagTypes tags)
+      public void Save (TagTypes tags)
       {
-         return Save (tags, true);
+         Save (tags, true);
       }
 
-      public override bool Save ()
+      public override void Save ()
       {
-         return Save (TagTypes.AllTags);
+         Save (TagTypes.AllTags);
       }
 
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/src/TagLib/Mpeg4/AppleTag.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Mpeg4/AppleTag.cs     2006-08-27 23:43:19 UTC 
(rev 64455)
+++ trunk/taglib-sharp/src/TagLib/Mpeg4/AppleTag.cs     2006-08-28 02:12:07 UTC 
(rev 64456)
@@ -1,3 +1,4 @@
+using System;
 using System.Collections;
 
 namespace TagLib.Mpeg4
@@ -168,14 +169,14 @@
       }
 
       // Save the file.
-      public bool Save ()
+      public void Save ()
       {
-         if (ilst_box == null)
-            return false;
+         if (ilst_box == null) {
+            throw new NullReferenceException();
+         }
          
          // Try to get into write mode.
-         try {file.Mode = File.AccessMode.Write;}
-         catch {return false;}
+         file.Mode = File.AccessMode.Write;
          
          // Make a file box.
          FileBox file_box = new FileBox (file);
@@ -279,15 +280,15 @@
                
                // Be nice and close the stream.
                file.Mode = File.AccessMode.Closed;
-               return true;
+               return;
             }
          }
          else
-            Debugger.Debug ("TagLib.Mpeg4.AppleTag.Save() - File doesn't even 
have a MOOV tag.");
+            throw new ApplicationException("stream does not have MOOV tag");
          
          // We're at the end. Close the stream and admit defeat.
          file.Mode = File.AccessMode.Closed;
-         return false;
+         throw new ApplicationException("Could not complete AppleTag save");
       }
       
       
//////////////////////////////////////////////////////////////////////////

Modified: trunk/taglib-sharp/src/TagLib/Mpeg4/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Mpeg4/File.cs 2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Mpeg4/File.cs 2006-08-28 02:12:07 UTC (rev 
64456)
@@ -45,7 +45,10 @@
       public override TagLib.AudioProperties AudioProperties {get {return 
properties;}}
       
       // Save. This work is done in the AppleTag.
-      public override bool Save () {return (tag == null) ? false : tag.Save 
();}
+      public override void Save () 
+      {
+        tag.Save();
+      }
       
       // Get the Apple Tag.
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/src/TagLib/Ogg/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Ogg/File.cs   2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/src/TagLib/Ogg/File.cs   2006-08-28 02:12:07 UTC (rev 
64456)
@@ -126,20 +126,13 @@
             dirty_packets.Add (i, p);
       }
       
-      public override bool Save ()
+      public override void Save ()
       {
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("Ogg.File.Save() - Cannot save to a read only 
file.");
-            return false;
+         if (IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("Ogg.File.Save() - Cannot save to a read only 
file.");
-            return false;
-         }
+         Mode = AccessMode.Write;
          
          IntList page_group = new IntList ();
 
@@ -157,7 +150,6 @@
          dirty_packets.Clear ();
          
          Mode = AccessMode.Closed;
-         return true;
       }
       
       

Modified: trunk/taglib-sharp/src/TagLib/Ogg/Flac/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Ogg/Flac/File.cs      2006-08-27 23:43:19 UTC 
(rev 64455)
+++ trunk/taglib-sharp/src/TagLib/Ogg/Flac/File.cs      2006-08-28 02:12:07 UTC 
(rev 64456)
@@ -70,7 +70,7 @@
       {
       }
 
-      public override bool Save ()
+      public override void Save ()
       {
          ClearPageData (); // Force re-reading of the file.
 
@@ -95,7 +95,7 @@
 
          SetPacket (comment_packet, v);
 
-         return base.Save ();
+         base.Save ();
       }
       
       

Modified: trunk/taglib-sharp/src/TagLib/Ogg/Vorbis/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Ogg/Vorbis/File.cs    2006-08-27 23:43:19 UTC 
(rev 64455)
+++ trunk/taglib-sharp/src/TagLib/Ogg/Vorbis/File.cs    2006-08-28 02:12:07 UTC 
(rev 64456)
@@ -64,7 +64,7 @@
       {
       }
       
-      public override bool Save ()
+      public override void Save ()
       {
          ClearPageData (); // Force re-reading of the file.
 
@@ -76,7 +76,7 @@
 
          SetPacket (1, v);
 
-         return base.Save ();
+         base.Save ();
       }
       
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Added: trunk/taglib-sharp/src/TagLib/ReadOnlyException.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/ReadOnlyException.cs  2006-08-27 23:43:19 UTC 
(rev 64455)
+++ trunk/taglib-sharp/src/TagLib/ReadOnlyException.cs  2006-08-28 02:12:07 UTC 
(rev 64456)
@@ -0,0 +1,36 @@
+/***************************************************************************
+    copyright            : (C) 2006 Novell, Inc.
+    email                : [EMAIL PROTECTED]
+ ***************************************************************************/
+
+/***************************************************************************
+ *   This library is free software; you can redistribute it and/or modify  *
+ *   it  under the terms of the GNU Lesser General Public License version  *
+ *   2.1 as published by the Free Software Foundation.                     *
+ *                                                                         *
+ *   This library is distributed in the hope that it will be useful, but   *
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
+ *   Lesser General Public License for more details.                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU Lesser General Public      *
+ *   License along with this library; if not, write to the Free Software   *
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
+ *   USA                                                                   *
+ ***************************************************************************/
+
+using System;
+
+namespace TagLib
+{
+    public class ReadOnlyException : ApplicationException 
+    {
+        public ReadOnlyException(string message) : base(message) 
+        {
+        }
+        
+        public ReadOnlyException() : base() 
+        {
+        }
+    }
+}

Modified: trunk/taglib-sharp/src/TagLib/WavPack/File.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/WavPack/File.cs       2006-08-27 23:43:19 UTC 
(rev 64455)
+++ trunk/taglib-sharp/src/TagLib/WavPack/File.cs       2006-08-28 02:12:07 UTC 
(rev 64456)
@@ -59,22 +59,14 @@
       {
       }
       
-      public override bool Save ()
+      public override void Save ()
       {
-         if (IsReadOnly)
-         {
-            Debugger.Debug ("WavPack.File.Save() -- File is read only.");
-            return false;
+         if(IsReadOnly) {
+            throw new ReadOnlyException();
          }
          
-         try {Mode = AccessMode.Write;}
-         catch
-         {
-            Debugger.Debug ("WavPack.File.Save() -- File is read only.");
-            return false;
-         }
-
-
+         Mode = AccessMode.Write;
+         
          // Update ID3v1 tag
          long id3v1_location = FindId3v1 ();
 
@@ -126,7 +118,6 @@
             RemoveBlock (ape_location, ape_size);
 
          Mode = AccessMode.Closed;
-         return true;
       }
       
       public override TagLib.Tag GetTag (TagTypes type, bool create)

Modified: trunk/taglib-sharp/taglib-sharp.csproj
===================================================================
--- trunk/taglib-sharp/taglib-sharp.csproj      2006-08-27 23:43:19 UTC (rev 
64455)
+++ trunk/taglib-sharp/taglib-sharp.csproj      2006-08-28 02:12:07 UTC (rev 
64456)
@@ -52,7 +52,8 @@
     <Compile Include="src\TagLib\StringList.cs" />
     <Compile Include="src\TagLib\SupportedMimeType.cs" />
     <Compile Include="src\TagLib\UnsupportedFormatException.cs" />
-    <Compile Include="src\TagLib\WavPack\File.cs" />
+    <Compile Include="src\TagLib\ReadOnlyException.cs" />
+       <Compile Include="src\TagLib\WavPack\File.cs" />
     <Compile Include="src\TagLib\WavPack\Properties.cs" />
     <Compile Include="src\TagLib\Ogg\File.cs" />
     <Compile Include="src\TagLib\Ogg\Page.cs" />

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to