UI/FindFileDialog.py

changeset 45
9a18f4dbb493
parent 42
23b45a742e17
child 53
c3eb7cc1ff8b
diff -r fe5cd20cb0eb -r 9a18f4dbb493 UI/FindFileDialog.py
--- a/UI/FindFileDialog.py	Sun Jan 10 13:59:15 2010 +0000
+++ b/UI/FindFileDialog.py	Sun Jan 10 19:19:52 2010 +0000
@@ -366,11 +366,9 @@
                 fn = file
             # read the file and split it into textlines
             try:
-                f = open(fn, 'r')
-                text = f.read()
+                text, encoding = Utilities.readEncodedFile(fn)
                 lines = text.splitlines()
-                f.close()
-            except (IOError, UnicodeError):
+            except (UnicodeError, IOError):
                 progress += 1
                 self.findProgress.setValue(progress)
                 continue
@@ -525,11 +523,9 @@
                 
                 # read the file and split it into textlines
                 try:
-                    f = open(fn, 'r')
-                    text = f.read()
+                    text, encoding = Utilities.readEncodedFile(fn)
                     lines = text.splitlines()
-                    f.close()
-                except IOError as err:
+                except (UnicodeError, IOError):
                     QMessageBox.critical(self,
                         self.trUtf8("Replace in Files"),
                         self.trUtf8("""<p>Could not read the file <b>{0}</b>."""
@@ -551,10 +547,8 @@
                 # write the file
                 txt = Utilities.linesep().join(lines)
                 try:
-                    f = open(fn, 'w')
-                    f.write(txt)
-                    f.close()
-                except IOError as err:
+                    Utilities.writeEncodedFile(fn, txt, encoding)
+                except (IOError, Utilities.CodingError, UnicodeError) as err:
                     QMessageBox.critical(self,
                         self.trUtf8("Replace in Files"),
                         self.trUtf8("""<p>Could not save the file <b>{0}</b>."""

eric ide

mercurial