helpers: fix whitespace and coding style
This commit is contained in:
parent
5f1fa163df
commit
dc61820baf
|
@ -14,13 +14,13 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
public static class SparkleHelpers
|
public static class SparkleHelpers {
|
||||||
{
|
|
||||||
|
|
||||||
public static bool ShowDebugInfo = true;
|
public static bool ShowDebugInfo = true;
|
||||||
|
|
||||||
|
@ -28,18 +28,15 @@ namespace SparkleLib {
|
||||||
// Show debug info if needed
|
// Show debug info if needed
|
||||||
public static void DebugInfo (string type, string message)
|
public static void DebugInfo (string type, string message)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ShowDebugInfo) {
|
if (ShowDebugInfo) {
|
||||||
|
|
||||||
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
|
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
|
||||||
|
|
||||||
if (message.StartsWith ("["))
|
if (!message.StartsWith ("["))
|
||||||
|
message = " " + message;
|
||||||
|
|
||||||
|
// TODO: Write to a log
|
||||||
Console.WriteLine ("[" + timestamp + "]" + "[" + type + "]" + message);
|
Console.WriteLine ("[" + timestamp + "]" + "[" + type + "]" + message);
|
||||||
else
|
|
||||||
Console.WriteLine ("[" + timestamp + "]" + "[" + type + "] " + message);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,23 +44,19 @@ namespace SparkleLib {
|
||||||
// two paths at once
|
// two paths at once
|
||||||
public static string CombineMore (params string [] parts)
|
public static string CombineMore (params string [] parts)
|
||||||
{
|
{
|
||||||
|
|
||||||
string new_path = "";
|
string new_path = "";
|
||||||
|
|
||||||
foreach (string part in parts)
|
foreach (string part in parts)
|
||||||
new_path = Path.Combine (new_path, part);
|
new_path = Path.Combine (new_path, part);
|
||||||
|
|
||||||
return new_path;
|
return new_path;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Recursively sets access rights of a folder to 'Normal'
|
// Recursively sets access rights of a folder to 'Normal'
|
||||||
public static void ClearAttributes (string path)
|
public static void ClearAttributes (string path)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Directory.Exists (path)) {
|
if (Directory.Exists (path)) {
|
||||||
|
|
||||||
string [] folders = Directory .GetDirectories (path);
|
string [] folders = Directory .GetDirectories (path);
|
||||||
|
|
||||||
foreach (string folder in folders)
|
foreach (string folder in folders)
|
||||||
|
@ -73,21 +66,15 @@ namespace SparkleLib {
|
||||||
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
File.SetAttributes (file, FileAttributes.Normal);
|
File.SetAttributes (file, FileAttributes.Normal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Converts a UNIX timestamp to a more usable time object
|
// Converts a UNIX timestamp to a more usable time object
|
||||||
public static DateTime UnixTimestampToDateTime (int timestamp)
|
public static DateTime UnixTimestampToDateTime (int timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
DateTime unix_epoch = new DateTime (1970, 1, 1, 0, 0, 0, 0);
|
DateTime unix_epoch = new DateTime (1970, 1, 1, 0, 0, 0, 0);
|
||||||
return unix_epoch.AddSeconds (timestamp);
|
return unix_epoch.AddSeconds (timestamp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue