Skip to content

Commit

Permalink
Fixer: Use GLib.File API directly (#182)
Browse files Browse the repository at this point in the history
We already have access to the File object so let's use it.
  • Loading branch information
tintou authored Nov 12, 2023
1 parent 965e477 commit 95cf9e6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Fixer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

public class ValaLint.Fixer : Object {
public void apply_fixes_for_file (File file, ref Vala.ArrayList<FormatMistake?> mistakes) throws Error, IOError {
var filename = file.get_path ();
string contents;
FileUtils.get_contents (filename, out contents);
uint8[] contents_data;
file.load_contents (null, out contents_data, null);
string contents = (string) (owned) contents_data;

var remaining_mistakes = new Vala.ArrayList<FormatMistake?> ((a, b) => a.equal_to (b));

Expand All @@ -46,6 +46,6 @@ public class ValaLint.Fixer : Object {
return a.begin.line - b.begin.line;
});

FileUtils.set_contents (filename, contents);
file.replace_contents (contents.data, null, false, FileCreateFlags.NONE, null);
}
}

0 comments on commit 95cf9e6

Please sign in to comment.