[controller] clean up user info members using regex
This commit is contained in:
parent
9441908871
commit
b3c4ab11f7
|
@ -21,6 +21,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
@ -491,14 +492,15 @@ namespace SparkleShare {
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
StreamReader reader = new StreamReader (global_config_file_path);
|
StreamReader reader = new StreamReader (global_config_file_path);
|
||||||
|
string global_config_file = reader.ReadToEnd ();
|
||||||
|
|
||||||
// Discard the first line
|
Regex regex = new Regex (@"name.+= (.+)");
|
||||||
reader.ReadLine ();
|
Match match = regex.Match (global_config_file);
|
||||||
|
|
||||||
string line = reader.ReadLine ();
|
if (match.Success)
|
||||||
reader.Close ();
|
return match.Groups [1].Value;
|
||||||
|
else
|
||||||
return line.Substring (line.IndexOf ("=") + 2);
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,16 +525,15 @@ namespace SparkleShare {
|
||||||
if (File.Exists (global_config_file_path)) {
|
if (File.Exists (global_config_file_path)) {
|
||||||
|
|
||||||
StreamReader reader = new StreamReader (global_config_file_path);
|
StreamReader reader = new StreamReader (global_config_file_path);
|
||||||
|
string global_config_file = reader.ReadToEnd ();
|
||||||
|
|
||||||
// TODO: Properly look at the variable name
|
Regex regex = new Regex (@"email.+= (.+)");
|
||||||
// Discard the first two lines
|
Match match = regex.Match (global_config_file);
|
||||||
reader.ReadLine ();
|
|
||||||
reader.ReadLine ();
|
|
||||||
|
|
||||||
string line = reader.ReadLine ();
|
if (match.Success)
|
||||||
reader.Close ();
|
return match.Groups [1].Value;
|
||||||
|
else
|
||||||
return line.Substring (line.IndexOf ("=") + 2);
|
return "";
|
||||||
|
|
||||||
} else { // Secondly, look at the user's private key file name
|
} else { // Secondly, look at the user's private key file name
|
||||||
|
|
||||||
|
@ -547,12 +548,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (file_name.StartsWith ("sparkleshare.") && file_name.EndsWith (".key")) {
|
if (file_name.StartsWith ("sparkleshare.") && file_name.EndsWith (".key")) {
|
||||||
|
|
||||||
string email = "";
|
Regex regex = new Regex (@"^sparkleshare\.(*)\.key$");
|
||||||
|
Match match = regex.Match (file_name);
|
||||||
|
|
||||||
email = file_name.Substring (file_name.IndexOf (".") + 1);
|
if (match.Success)
|
||||||
email = email.Substring (0, email.LastIndexOf ("."));
|
return match.Groups [1].Value;
|
||||||
|
else
|
||||||
return email;
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue