Bug 663075 - FileUtils.jsm should have an easy way to create an nsILocalFile with a path; r=sdwilsh sr=rstrong
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 20 Sep 2011 17:20:51 +0100
changeset 78242 ebbc50bbebeb2b3142efd9fbde0d0be0666008f9
parent 78241 028baeb2ca2125590df8cae87beabf91b25e2117
child 78243 969aaa109a23e2f9a0fe3a4efa0642f67d938d88
push id340
push userclegnitto@mozilla.com
push dateTue, 08 Nov 2011 22:56:33 +0000
treeherdermozilla-beta@f745dc151615 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh, rstrong
bugs663075
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 663075 - FileUtils.jsm should have an easy way to create an nsILocalFile with a path; r=sdwilsh sr=rstrong
toolkit/mozapps/shared/FileUtils.jsm
toolkit/mozapps/shared/test/unit/test_FileUtils.js
--- a/toolkit/mozapps/shared/FileUtils.jsm
+++ b/toolkit/mozapps/shared/FileUtils.jsm
@@ -153,10 +153,12 @@ var FileUtils = {
       try {
         stream.finish();
         return;
       }
       catch (e) {
       }
     }
     stream.close();
-  }
+  },
+
+  File: Components.Constructor("@mozilla.org/file/local;1", Ci.nsILocalFile, "initWithPath")
 };
--- a/toolkit/mozapps/shared/test/unit/test_FileUtils.js
+++ b/toolkit/mozapps/shared/test/unit/test_FileUtils.js
@@ -179,11 +179,21 @@ add_test(function test_closeSafeFileOutp
   // But once we close it, we can't anymore.
   FileUtils.closeSafeFileOutputStream(fos);
   do_check_throws(function () {
     fos.write(data, data.length);
   }, Components.results.NS_BASE_STREAM_CLOSED);
   run_next_test();
 });
 
+add_test(function test_newFile() {
+  let testfile = FileUtils.getFile("ProfD", ["test"]);
+  let testpath = testfile.path;
+  let file = new FileUtils.File(testpath);
+  do_check_true(file instanceof Components.interfaces.nsILocalFile);
+  do_check_true(file.equals(testfile));
+  do_check_eq(file.path, testpath);
+  run_next_test();
+});
+
 function run_test() {
   run_next_test();
 }