Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoFixTest: fix indentation, other code style for copy_recursive () #184

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions test/AutoFixTest.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ class AutoFixTest : GLib.Object {
Vala.ArrayList<ValaLint.FormatMistake?> mistakes;
}

public bool copy_recursive (GLib.File src, GLib.File dest, GLib.FileCopyFlags flags = GLib.FileCopyFlags.NONE,
GLib.Cancellable? cancellable = null) throws GLib.Error {
GLib.FileType src_type = src.query_file_type (GLib.FileQueryInfoFlags.NONE, cancellable);
if (src_type == GLib.FileType.DIRECTORY) {
public bool copy_recursive (
GLib.File src,
GLib.File dest,
GLib.FileCopyFlags flags = NONE,
GLib.Cancellable? cancellable = null
) throws GLib.Error {
var src_type = src.query_file_type (NONE, cancellable);
if (src_type == DIRECTORY) {
if (!dest.query_exists ()) {
dest.make_directory (cancellable);
}
Expand All @@ -41,22 +45,27 @@ class AutoFixTest : GLib.Object {

string src_path = src.get_path ();
string dest_path = dest.get_path ();
GLib.FileEnumerator enumerator = src.enumerate_children (GLib.FileAttribute.STANDARD_NAME,
GLib.FileQueryInfoFlags.NONE, cancellable);

for ( GLib.FileInfo? info = enumerator.next_file (cancellable);
info != null ; info = enumerator.next_file (cancellable) ) {
copy_recursive (
GLib.File.new_for_path (GLib.Path.build_filename (src_path, info.get_name ())),
GLib.File.new_for_path (GLib.Path.build_filename (dest_path, info.get_name ())),
flags,
cancellable);
var enumerator = src.enumerate_children (
GLib.FileAttribute.STANDARD_NAME, NONE, cancellable
);

for (
GLib.FileInfo? info = enumerator.next_file (cancellable);
info != null;
info = enumerator.next_file (cancellable)
) {
copy_recursive (
GLib.File.new_for_path (GLib.Path.build_filename (src_path, info.get_name ())),
GLib.File.new_for_path (GLib.Path.build_filename (dest_path, info.get_name ())),
flags,
cancellable
);
}
} else if ( src_type == GLib.FileType.REGULAR) {
} else if (src_type == REGULAR) {
src.copy (dest, flags, cancellable);
}
}

return true;
return true;
}

public Vala.ArrayList<File> get_test_files_from_dir (File dir) throws Error, IOError {
Expand Down Expand Up @@ -99,7 +108,7 @@ class AutoFixTest : GLib.Object {
assert (inital_auto_fix_files_dir.query_exists ());

try {
copy_recursive (inital_auto_fix_files_dir, output_dir, FileCopyFlags.OVERWRITE);
copy_recursive (inital_auto_fix_files_dir, output_dir, OVERWRITE);
} catch (Error e) {
error ("Error!: %s", e.message);
}
Expand Down