From a37a0410187998bd7771b73e573cb58ea1437dcd Mon Sep 17 00:00:00 2001 From: praktikant Date: Tue, 24 Jan 2012 10:33:30 +0100 Subject: [PATCH] Fixing #298 again first try --- SparkleLib/Git/SparkleRepoGit.cs | 10 ++++----- SparkleLib/Makefile.am | 1 + SparkleLib/SparkleExtensions.cs | 35 ++++++++++++++++++++++++++++++++ SparkleLib/SparkleLib.csproj | 1 + 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 SparkleLib/SparkleExtensions.cs diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index a68cc8cb..fed5778d 100755 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -71,7 +71,7 @@ namespace SparkleLib { public override double Size { get { - string file_path = Path.Combine (LocalPath, ".git", "repo_size"); + string file_path = new string [] {LocalPath, ".git", "repo_size"}.Combine(); try { return double.Parse (File.ReadAllText (file_path)); @@ -85,7 +85,7 @@ namespace SparkleLib { public override double HistorySize { get { - string file_path = Path.Combine (LocalPath, ".git", "repo_history_size"); + string file_path = new string [] {LocalPath, ".git", "repo_history_size"}.Combine(); try { return double.Parse (File.ReadAllText (file_path)); @@ -103,10 +103,10 @@ namespace SparkleLib { new DirectoryInfo (LocalPath)); double history_size = CalculateSize ( - new DirectoryInfo (Path.Combine (LocalPath, ".git"))); + new DirectoryInfo (new string [] {LocalPath, ".git"}.Combine() )); - string size_file_path = Path.Combine (LocalPath, ".git", "repo_size"); - string history_size_file_path = Path.Combine (LocalPath, ".git", "repo_history_size"); + string size_file_path = new string [] {LocalPath, ".git", "repo_size"}.Combine(); + string history_size_file_path = new string [] {LocalPath, ".git", "repo_history_size"}.Combine(); File.WriteAllText (size_file_path, size.ToString ()); File.WriteAllText (history_size_file_path, history_size.ToString ()); diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am index 3dd3ac2f..502e3a6f 100755 --- a/SparkleLib/Makefile.am +++ b/SparkleLib/Makefile.am @@ -3,6 +3,7 @@ TARGET = library SOURCES = \ Defines.cs \ + SparkleExtensions.cs \ Git/SparkleFetcherGit.cs \ Git/SparkleGit.cs \ Git/SparkleRepoGit.cs \ diff --git a/SparkleLib/SparkleExtensions.cs b/SparkleLib/SparkleExtensions.cs new file mode 100755 index 00000000..38e30e0a --- /dev/null +++ b/SparkleLib/SparkleExtensions.cs @@ -0,0 +1,35 @@ +// SparkleShare, a collaboration and sharing tool. +// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com) +// +// 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 +// (at your option) 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 (http://www.gnu.org/licenses/). + + +using System; +using System.IO; + +namespace SparkleLib { + + public static class Extensions { + + public static string Combine (this String [] parts) + { + string new_path = ""; + + foreach (string part in parts) + new_path = Path.Combine (new_path, part); + + return new_path; + } + } +} diff --git a/SparkleLib/SparkleLib.csproj b/SparkleLib/SparkleLib.csproj index a0ac9494..1c708116 100755 --- a/SparkleLib/SparkleLib.csproj +++ b/SparkleLib/SparkleLib.csproj @@ -49,6 +49,7 @@ +