[Frugalware-git] frugal-tweak: *save locale/hostname
bouleetbil
bouleetbil at frogdev.info
Sun Sep 5 21:47:42 CEST 2010
Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=7dbe31469d888b148c66571c0c35ff0aee8bdfe6
commit 7dbe31469d888b148c66571c0c35ff0aee8bdfe6
Author: bouleetbil <bouleetbil at frogdev.info>
Date: Sun Sep 5 21:47:37 2010 +0200
*save locale/hostname
diff --git a/frugal-mono-tools/ConfSystem.cs b/frugal-mono-tools/ConfSystem.cs
index 9b582af..e931e02 100644
--- a/frugal-mono-tools/ConfSystem.cs
+++ b/frugal-mono-tools/ConfSystem.cs
@@ -15,14 +15,17 @@
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// */
-using System;
+using System;
+using System.IO;
namespace frugalmonotools
{
public class ConfSystem
{
const string cch_hostname =@"/etc/HOSTNAME";
const string cch_release=@"/etc/frugalware-release";
+ const string cch_locale=@"/etc/profile.d/lang.sh";
private string _hostname;
+ private string _locale;
private string _distribution; //can't change it
public string GetHostname()
{
@@ -44,11 +47,54 @@ namespace frugalmonotools
}
public string GetLocale() {
return Mono.Unix.Native.Syscall.getenv("LANG");
+ }
+ public void SetLocale(string locale) {
+ _locale=locale;
}
public ConfSystem ()
{
this.SetHostname(Outils.ReadFile(cch_hostname).ToString().Replace("\n",""));
this._distribution=Outils.ReadFile(cch_release).ToString().Replace("\n","");
+ }
+ public void Save()
+ {
+ try
+ {
+ //save hostname
+ StreamWriter FileConf = new StreamWriter(cch_hostname);
+ FileConf.WriteLine(this.GetHostname());
+ FileConf.Close();
+ //locale
+ //search export LANG=
+ string content = Outils.ReadFile(cch_locale);
+ string[] lines = content.Split('\n');
+ string[] linesResult = new string[lines.Length];
+ string lineResult;
+ int i =0;
+ foreach (string line in lines)
+ {
+ lineResult=line;
+ if (lineResult.IndexOf("export LANG")>=0)
+ {
+ lineResult="export LANG="+_locale;
+ }
+ linesResult[i]=lineResult;
+ i++;
+ }
+ //now save locale
+ FileConf = new StreamWriter(cch_locale);
+ foreach (string line in linesResult)
+ {
+ FileConf.WriteLine(line);
+ }
+ FileConf.Close();
+
+ }
+ catch(Exception exe)
+ {
+ Console.WriteLine("Can't save configuration");
+ Console.WriteLine(exe.Message);
+ }
}
}
}
More information about the Frugalware-git
mailing list