[gnome-games] archive: Rename to FileOperations and make it a class
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] archive: Rename to FileOperations and make it a class
- Date: Sun, 19 May 2019 18:10:02 +0000 (UTC)
commit 0aa26d7be67dea4932b8ae3a8c2c010683f4a206
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sun May 19 23:05:53 2019 +0500
archive: Rename to FileOperations and make it a class
Since there's no name clash with libarchive anymore, it can be a proper
class with static methods instead of plain functions.
src/meson.build | 2 +-
src/ui/application.vala | 4 ++--
src/utils/{archive.vala => file-operations.vala} | 12 ++++++------
3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 4ed5cc5e..735a4951 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -182,7 +182,6 @@ vala_sources = [
'ui/shortcuts-window.vala',
'ui/ui-view.vala',
- 'utils/archive.vala',
'utils/composite-cover.vala',
'utils/composite-title.vala',
'utils/cue-sheet/cue-sheet.vala',
@@ -192,6 +191,7 @@ vala_sources = [
'utils/cue-sheet/cue-sheet-track-mode.vala',
'utils/cue-sheet/cue-sheet-track-node.vala',
'utils/directory.vala',
+ 'utils/file-operations.vala',
'utils/filename-title.vala',
'utils/fingerprint.vala',
'utils/grep.vala',
diff --git a/src/ui/application.vala b/src/ui/application.vala
index d1159fd0..747eb119 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -451,13 +451,13 @@ public class Games.Application : Gtk.Application {
var data_dir = Application.get_data_dir ();
string[] database = { Application.get_database_path () };
- extract_archive (archive_path, data_dir, database);
+ FileOperations.extract_archive (archive_path, data_dir, database);
}
public static void backup_to (string file_path) throws CompressionError {
var data_dir = File.new_for_path (Application.get_data_dir ());
string[] database = { Application.get_database_path () };
- compress_dir (file_path, data_dir, data_dir, database);
+ FileOperations.compress_dir (file_path, data_dir, data_dir, database);
}
}
diff --git a/src/utils/archive.vala b/src/utils/file-operations.vala
similarity index 88%
rename from src/utils/archive.vala
rename to src/utils/file-operations.vala
index 005605e4..41e37b41 100644
--- a/src/utils/archive.vala
+++ b/src/utils/file-operations.vala
@@ -14,8 +14,8 @@ public errordomain Games.ExtractionError {
DIDNT_REACH_EOF,
}
-namespace Games {
- private void compress_dir (string name, File parent_dir, File export_data, string[]? exclude_files =
null) throws CompressionError {
+public class Games.FileOperations {
+ public static void compress_dir (string name, File parent_dir, File export_data, string[]?
exclude_files = null) throws CompressionError {
var archive = new Archive.Write ();
archive.add_filter_gzip ();
archive.set_format_pax_restricted ();
@@ -28,7 +28,7 @@ namespace Games {
}
}
- private void backup_data (File parent, File dir, Archive.Write archive, string[] exclusions) throws
CompressionError {
+ private static void backup_data (File parent, File dir, Archive.Write archive, string[] exclusions)
throws CompressionError {
var dtype = dir.query_file_type (FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
if (dtype == FileType.DIRECTORY) {
@@ -52,7 +52,7 @@ namespace Games {
}
}
- private void compress_files (File parent_working_dir, File export_dir, Archive.Write export_archive)
throws CompressionError {
+ private static void compress_files (File parent_working_dir, File export_dir, Archive.Write
export_archive) throws CompressionError {
FileInfo export_info;
FileInputStream input_stream;
DataInputStream data_input_stream;
@@ -94,7 +94,7 @@ namespace Games {
}
}
- private void delete_files (File file, string[] exclusions) throws Error {
+ public static void delete_files (File file, string[] exclusions) throws Error {
var dtype = file.query_file_type (FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
if (dtype == FileType.DIRECTORY) {
@@ -113,7 +113,7 @@ namespace Games {
}
}
- private void extract_archive (string archive_path, string extract_dir, string[] exclude) throws
ExtractionError {
+ public static void extract_archive (string archive_path, string extract_dir, string[] exclude) throws
ExtractionError {
try {
var file_dir = File.new_for_path (extract_dir);
delete_files (file_dir, exclude);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]