@@ -241,11 +241,9 @@ const RuleWriter = {
241241 return rv ;
242242 } ,
243243
244- read : function ( file , rule_store , ruleset_id ) {
244+ read : function ( file ) {
245245 if ( ! file . exists ( ) )
246246 return null ;
247- if ( ( rule_store . targets == null ) && ( rule_store . targets != { } ) )
248- this . log ( WARN , "TARGETS IS NULL" ) ;
249247 var data = "" ;
250248 var fstream = CC [ "@mozilla.org/network/file-input-stream;1" ]
251249 . createInstance ( CI . nsIFileInputStream ) ;
@@ -262,6 +260,28 @@ const RuleWriter = {
262260
263261 sstream . close ( ) ;
264262 fstream . close ( ) ;
263+ return data ;
264+ } ,
265+
266+ write : function ( file , data ) {
267+ //if (!file.exists())
268+ // return null;
269+ this . log ( DBUG , "Opening " + file . path + " for writing" ) ;
270+ var fstream = CC [ "@mozilla.org/network/file-output-stream;1" ]
271+ . createInstance ( CI . nsIFileOutputStream ) ;
272+ fstream . init ( file , - 1 , - 1 , 0 ) ;
273+
274+ var retval = fstream . write ( data , data . length ) ;
275+ this . log ( DBUG , "Got retval " + retval ) ;
276+ fstream . close ( ) ;
277+ return data ;
278+ } ,
279+
280+ rulesetFromFile : function ( file , rule_store , ruleset_id ) {
281+ if ( ( rule_store . targets == null ) && ( rule_store . targets != { } ) )
282+ this . log ( WARN , "TARGETS IS NULL" ) ;
283+ var data = this . read ( file ) ;
284+ if ( ! data ) return null ;
265285 return this . readFromString ( data , rule_store , ruleset_id ) ;
266286 } ,
267287
0 commit comments