Add String.Combine () extenstion method for long paths. Fixes #298
This commit is contained in:
parent
4236727079
commit
5560bf43b6
|
@ -20,6 +20,7 @@ SOURCES = \
|
|||
SparkleEntry.cs \
|
||||
SparkleEventLog.cs \
|
||||
SparkleEventLogController.cs \
|
||||
SparkleExtensions.cs \
|
||||
SparkleLinController.cs \
|
||||
SparkleSetup.cs \
|
||||
SparkleSetupController.cs \
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace SparkleShare {
|
|||
if (name == null)
|
||||
return GetLog ();
|
||||
|
||||
string path = Path.Combine (new string [] {SparkleConfig.DefaultConfig.FoldersPath, name});
|
||||
string path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, name}.Combine ();
|
||||
int log_size = 50;
|
||||
|
||||
foreach (SparkleRepoBase repo in Repositories) {
|
||||
|
@ -350,9 +350,8 @@ namespace SparkleShare {
|
|||
} else {
|
||||
if (change_set.Edited.Count > 0) {
|
||||
foreach (string file_path in change_set.Edited) {
|
||||
string absolute_file_path = Path.Combine (
|
||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path});
|
||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path}.Combine ();
|
||||
|
||||
if (File.Exists (absolute_file_path))
|
||||
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||
|
@ -363,9 +362,8 @@ namespace SparkleShare {
|
|||
|
||||
if (change_set.Added.Count > 0) {
|
||||
foreach (string file_path in change_set.Added) {
|
||||
string absolute_file_path = Path.Combine (
|
||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path});
|
||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path}.Combine ();
|
||||
|
||||
if (File.Exists (absolute_file_path))
|
||||
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||
|
@ -376,9 +374,8 @@ namespace SparkleShare {
|
|||
|
||||
if (change_set.Deleted.Count > 0) {
|
||||
foreach (string file_path in change_set.Deleted) {
|
||||
string absolute_file_path = Path.Combine (
|
||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path});
|
||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path}.Combine ();
|
||||
|
||||
if (File.Exists (absolute_file_path))
|
||||
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||
|
@ -392,13 +389,11 @@ namespace SparkleShare {
|
|||
foreach (string file_path in change_set.MovedFrom) {
|
||||
string to_file_path = change_set.MovedTo [i];
|
||||
|
||||
string absolute_file_path = Path.Combine (
|
||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path});
|
||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path}.Combine ();
|
||||
|
||||
string absolute_to_file_path = Path.Combine (
|
||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, file_path});
|
||||
string absolute_to_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||
change_set.Folder, to_file_path}.Combine ();
|
||||
|
||||
if (File.Exists (absolute_file_path))
|
||||
event_entry += "<dd class='document moved'><a href='" + absolute_file_path + "'>" + file_path + "</a><br/>";
|
||||
|
@ -901,9 +896,9 @@ namespace SparkleShare {
|
|||
{
|
||||
List<string> old_avatars = new List<string> ();
|
||||
bool avatar_fetched = false;
|
||||
string avatar_path = Path.Combine (
|
||||
new string [] {Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons",
|
||||
size + "x" + size, "status"});
|
||||
string avatar_path = new string [] {
|
||||
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath),
|
||||
"icons", size + "x" + size, "status"}.Combine ();
|
||||
|
||||
if (!Directory.Exists (avatar_path)) {
|
||||
Directory.CreateDirectory (avatar_path);
|
||||
|
|
35
SparkleShare/SparkleExtensions.cs
Normal file
35
SparkleShare/SparkleExtensions.cs
Normal file
|
@ -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 SparkleShare {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -77,5 +77,6 @@
|
|||
<Compile Include="SparkleEventLog.cs" />
|
||||
<Compile Include="SparkleAboutController.cs" />
|
||||
<Compile Include="SparkleAbout.cs" />
|
||||
<Compile Include="SparkleExtensions.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue