From e999dceb733bece577b2c08dcab08b39cff3fefe Mon Sep 17 00:00:00 2001 From: "markh%activestate.com" Date: Wed, 8 Aug 2001 02:25:18 +0000 Subject: [PATCH] nsIFile objects are "remove"d, not "delete"d. Add tests to cover this case. Not part of the build. git-svn-id: svn://10.0.0.236/trunk@100554 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/python/xpcom/file.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mozilla/extensions/python/xpcom/file.py b/mozilla/extensions/python/xpcom/file.py index 41bad2b57e4..6cb624f996d 100644 --- a/mozilla/extensions/python/xpcom/file.py +++ b/mozilla/extensions/python/xpcom/file.py @@ -175,7 +175,7 @@ class LocalFile(_File): if mode in ["w","a"]: if mode== "w": if file.exists(): - file.delete(0) + file.remove(0) moz_mode = NS_CREATE_FILE | NS_WRONLY elif mode=="a": moz_mode = NS_APPEND @@ -252,6 +252,18 @@ def _TestLocalFile(): else: print "Chunks read the correct data." test_file.close() + # Open the same file again for writing - this should delete the old one. + if not os.path.isfile(fname): + raise RuntimeError, "The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,) + test_file = LocalFile(fname, "w") + test_file.write(data) + test_file.close() + # Make sure Python can read it OK. + f = open(fname, "r") + if f.read() != data: + print "Eeek - Python could not read the data back correctly after recreating an existing file!" + f.close() + # XXX - todo - test "a" mode! finally: try: