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 \
|
SparkleEntry.cs \
|
||||||
SparkleEventLog.cs \
|
SparkleEventLog.cs \
|
||||||
SparkleEventLogController.cs \
|
SparkleEventLogController.cs \
|
||||||
|
SparkleExtensions.cs \
|
||||||
SparkleLinController.cs \
|
SparkleLinController.cs \
|
||||||
SparkleSetup.cs \
|
SparkleSetup.cs \
|
||||||
SparkleSetupController.cs \
|
SparkleSetupController.cs \
|
||||||
|
|
|
@ -246,7 +246,7 @@ namespace SparkleShare {
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return GetLog ();
|
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;
|
int log_size = 50;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
|
@ -350,9 +350,8 @@ namespace SparkleShare {
|
||||||
} else {
|
} else {
|
||||||
if (change_set.Edited.Count > 0) {
|
if (change_set.Edited.Count > 0) {
|
||||||
foreach (string file_path in change_set.Edited) {
|
foreach (string file_path in change_set.Edited) {
|
||||||
string absolute_file_path = Path.Combine (
|
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
change_set.Folder, file_path}.Combine ();
|
||||||
change_set.Folder, file_path});
|
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
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) {
|
if (change_set.Added.Count > 0) {
|
||||||
foreach (string file_path in change_set.Added) {
|
foreach (string file_path in change_set.Added) {
|
||||||
string absolute_file_path = Path.Combine (
|
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
change_set.Folder, file_path}.Combine ();
|
||||||
change_set.Folder, file_path});
|
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
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) {
|
if (change_set.Deleted.Count > 0) {
|
||||||
foreach (string file_path in change_set.Deleted) {
|
foreach (string file_path in change_set.Deleted) {
|
||||||
string absolute_file_path = Path.Combine (
|
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
change_set.Folder, file_path}.Combine ();
|
||||||
change_set.Folder, file_path});
|
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
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) {
|
foreach (string file_path in change_set.MovedFrom) {
|
||||||
string to_file_path = change_set.MovedTo [i];
|
string to_file_path = change_set.MovedTo [i];
|
||||||
|
|
||||||
string absolute_file_path = Path.Combine (
|
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
change_set.Folder, file_path}.Combine ();
|
||||||
change_set.Folder, file_path});
|
|
||||||
|
|
||||||
string absolute_to_file_path = Path.Combine (
|
string absolute_to_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
||||||
new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
change_set.Folder, to_file_path}.Combine ();
|
||||||
change_set.Folder, file_path});
|
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document moved'><a href='" + absolute_file_path + "'>" + file_path + "</a><br/>";
|
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> ();
|
List<string> old_avatars = new List<string> ();
|
||||||
bool avatar_fetched = false;
|
bool avatar_fetched = false;
|
||||||
string avatar_path = Path.Combine (
|
string avatar_path = new string [] {
|
||||||
new string [] {Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons",
|
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath),
|
||||||
size + "x" + size, "status"});
|
"icons", size + "x" + size, "status"}.Combine ();
|
||||||
|
|
||||||
if (!Directory.Exists (avatar_path)) {
|
if (!Directory.Exists (avatar_path)) {
|
||||||
Directory.CreateDirectory (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="SparkleEventLog.cs" />
|
||||||
<Compile Include="SparkleAboutController.cs" />
|
<Compile Include="SparkleAboutController.cs" />
|
||||||
<Compile Include="SparkleAbout.cs" />
|
<Compile Include="SparkleAbout.cs" />
|
||||||
|
<Compile Include="SparkleExtensions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in a new issue