prepare v2.2

This commit is contained in:
guinux
2015-03-04 15:55:36 +01:00
parent aea3a143d7
commit eb9ace7b82
89 changed files with 3038 additions and 1696 deletions

View File

@@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
*
* 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
@@ -57,9 +57,9 @@ namespace Alpm {
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -68,19 +68,25 @@ namespace Alpm {
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
line = line.strip ();
if (line.length == 0) continue;
if (line[0] == '#') continue;
if (line.length == 0) {
continue;
}
if (line[0] == '#') {
continue;
}
string[] splitted = line.split ("=");
string _key = splitted[0].strip ();
string _value = null;
if (splitted[1] != null)
if (splitted[1] != null) {
_value = splitted[1].strip ();
if (_key == "Method")
}
if (_key == "Method") {
choosen_generation_method = _value;
else if (_key == "OnlyCountry")
} else if (_key == "OnlyCountry") {
choosen_country = _value;
else if (_key == "MirrorlistsDir")
} else if (_key == "MirrorlistsDir") {
mirrorlists_dir = _value.replace ("\"", "");
}
}
} catch (Error e) {
GLib.stderr.printf("%s\n", e.message);
@@ -90,9 +96,9 @@ namespace Alpm {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
else {
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@@ -105,19 +111,23 @@ namespace Alpm {
if (new_conf.contains ("Method")) {
string _value = new_conf.get ("Method").get_string ();
data += "Method=%s\n".printf (_value);
} else
} else {
data += line + "\n";
}
} else if (line.contains ("OnlyCountry")) {
if (new_conf.contains ("OnlyCountry")) {
string _value = new_conf.get ("OnlyCountry").get_string ();
if (_value == dgettext (null, "Worldwide"))
if (_value == dgettext (null, "Worldwide")) {
data += "#%s\n".printf (line);
else
} else {
data += "OnlyCountry=%s\n".printf (_value);
} else
}
} else {
data += line + "\n";
} else
}
} else {
data += line + "\n";
}
}
// delete the file before rewrite it
file.delete ();