From dfb09f56dad2463602823fdc3b34d2c1020ba9c6 Mon Sep 17 00:00:00 2001 From: Nikolay Brovko Date: Fri, 24 Jan 2020 18:22:20 +0300 Subject: [PATCH] put mktempdir to utils namespace --- src/main.vala | 10 +--------- src/meson.build | 1 + src/utils.vala | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/utils.vala diff --git a/src/main.vala b/src/main.vala index 2c112da..cf01da9 100644 --- a/src/main.vala +++ b/src/main.vala @@ -112,20 +112,12 @@ int download () { } -string mktempdir () throws Error { - - string temp_dir = null; - Process.spawn_command_line_sync ("mktemp -d", out temp_dir); - return temp_dir.strip (); - -} - int update () { try { unowned string repo_url = Environment.get_variable ("YGG_UPDATE_REPO"); - string temp_dir = mktempdir (); + string temp_dir = Utils.mktempdir (); if (repo_url == null) { repo_url = "https://git.macaw.me/plant_1312/Yggtk.git"; diff --git a/src/meson.build b/src/meson.build index 5e822c1..48702c5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,6 @@ yggtk_sources = [ 'main.vala', + 'utils.vala', ] yggtk = executable( diff --git a/src/utils.vala b/src/utils.vala new file mode 100644 index 0000000..b072b56 --- /dev/null +++ b/src/utils.vala @@ -0,0 +1,26 @@ +/** + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace Utils { + + string mktempdir () throws Error { + + string temp_dir = null; + Process.spawn_command_line_sync ("mktemp -d", out temp_dir); + return temp_dir.strip (); + + } + +} \ No newline at end of file