Moved basic IO helper functions to Library.IO.
This commit is contained in:
@@ -171,6 +171,10 @@
|
||||
<Project>{B20A7CEE-9C5B-47B9-8B76-BC85ADFE8493}</Project>
|
||||
<Name>Duplicati.Library.Backend.Dropbox</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Library\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="help.txt" />
|
||||
|
||||
@@ -18,7 +18,8 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.CommandLine.RecoveryTool
|
||||
{
|
||||
public static class Restore
|
||||
@@ -148,7 +149,7 @@ namespace Duplicati.CommandLine.RecoveryTool
|
||||
Console.WriteLine("Restoring {0} files to {1}", filecount, string.IsNullOrWhiteSpace(targetpath) ? "original position" : targetpath);
|
||||
|
||||
if (Library.Utility.Utility.IsClientLinux || largestprefix.Length > 0)
|
||||
largestprefix = Library.Utility.Utility.AppendDirSeparator(largestprefix);
|
||||
largestprefix = Util.AppendDirSeparator(largestprefix);
|
||||
|
||||
if (!string.IsNullOrEmpty(largestprefix))
|
||||
Console.WriteLine("Removing common prefix {0} from files", largestprefix);
|
||||
|
||||
@@ -78,12 +78,18 @@
|
||||
</Reference>
|
||||
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
||||
<HintPath>..\..\..\thirdparty\appindicator-sharp\gdk-sharp.dll</HintPath>
|
||||
<Package>gtk-sharp-2.0</Package>
|
||||
</Reference>
|
||||
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
||||
<HintPath>..\..\..\thirdparty\appindicator-sharp\gtk-sharp.dll</HintPath>
|
||||
<Package>gtk-sharp-2.0</Package>
|
||||
</Reference>
|
||||
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
||||
<Package>glib-sharp-2.0</Package>
|
||||
</Reference>
|
||||
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
||||
<Package>gtk-sharp-2.0</Package>
|
||||
</Reference>
|
||||
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
||||
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
||||
<Reference Include="MonoMac">
|
||||
<HintPath>..\..\..\thirdparty\MonoMac\MonoMac.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -334,6 +340,10 @@
|
||||
<Project>{0797AA22-C5DD-4950-BB60-34765AB8C6DD}</Project>
|
||||
<Name>Duplicati.Tools</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Library\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Duplicati.Library.IO;
|
||||
using Duplicati.Server.Serialization;
|
||||
using Duplicati.Server.Serialization.Interface;
|
||||
|
||||
@@ -76,7 +77,7 @@ namespace Duplicati.GUI.TrayIcon
|
||||
|
||||
public HttpServerConnection(Uri server, string password, bool saltedpassword, Program.PasswordSource passwordSource, bool disableTrayIconLogin, Dictionary<string, string> options)
|
||||
{
|
||||
m_baseUri = Duplicati.Library.Utility.Utility.AppendDirSeparator(server.ToString(), "/");
|
||||
m_baseUri = Util.AppendDirSeparator(server.ToString(), "/");
|
||||
|
||||
m_apiUri = m_baseUri + "api/v1";
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@
|
||||
<Project>{4D012CB1-4B92-47F4-89B7-BF80A73A2E99}</Project>
|
||||
<Name>Duplicati.License</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="AutoUpdateAppName.txt" />
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.AutoUpdater
|
||||
{
|
||||
public static class Program
|
||||
@@ -61,7 +62,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
{
|
||||
var versions = UpdaterManager.FindInstalledVersions();
|
||||
var selfdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
if (string.Equals(Library.Utility.Utility.AppendDirSeparator(selfdir), Library.Utility.Utility.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
|
||||
if (string.Equals(Util.AppendDirSeparator(selfdir), Util.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
|
||||
versions = versions.Union(new KeyValuePair<string, UpdateInfo>[] { new KeyValuePair<string, UpdateInfo>(selfdir, UpdaterManager.SelfVersion) });
|
||||
Console.WriteLine(string.Join(Environment.NewLine, versions.Select(x => string.Format(" {0} {1} ({2})", (x.Value.Version == UpdaterManager.SelfVersion.Version ? "*" : "-"), x.Value.Displayname, x.Value.Version))));
|
||||
return 0;
|
||||
@@ -71,7 +72,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
{
|
||||
var versions = UpdaterManager.FindInstalledVersions();
|
||||
var selfdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
if (string.Equals(Library.Utility.Utility.AppendDirSeparator(selfdir), Library.Utility.Utility.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
|
||||
if (string.Equals(Util.AppendDirSeparator(selfdir), Util.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
|
||||
versions = versions.Union(new KeyValuePair<string, UpdateInfo>[] { new KeyValuePair<string, UpdateInfo>(selfdir, UpdaterManager.SelfVersion) });
|
||||
|
||||
Console.WriteLine(string.Join(Environment.NewLine, versions.Select(x => string.Format(" {0} {1} ({2}): {3}", (x.Value.Version == UpdaterManager.SelfVersion.Version ? "*" : "-"), x.Value.Displayname, x.Value.Version, UpdaterManager.VerifyUnpackedFolder(x.Key, x.Value) ? "Valid" : "*** Modified ***"))));
|
||||
|
||||
@@ -21,7 +21,8 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.AutoUpdater
|
||||
{
|
||||
public enum AutoUpdateStrategy
|
||||
@@ -149,7 +150,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
var attempts = new List<string>();
|
||||
|
||||
// We do not want to install anything in the basedir, if the application is installed in "ProgramFiles"
|
||||
if (!string.IsNullOrWhiteSpace(programfiles) && !InstalledBaseDir.StartsWith(Library.Utility.Utility.AppendDirSeparator(programfiles), StringComparison.Ordinal))
|
||||
if (!string.IsNullOrWhiteSpace(programfiles) && !InstalledBaseDir.StartsWith(Util.AppendDirSeparator(programfiles), StringComparison.Ordinal))
|
||||
attempts.Add(System.IO.Path.Combine(InstalledBaseDir, "updates"));
|
||||
|
||||
if (Library.Utility.Utility.IsClientOSX)
|
||||
@@ -510,7 +511,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
|
||||
System.IO.Directory.CreateDirectory(targetfolder);
|
||||
|
||||
var tempfolderpath = Duplicati.Library.Utility.Utility.AppendDirSeparator(tempfolder);
|
||||
var tempfolderpath = Util.AppendDirSeparator(tempfolder);
|
||||
var tempfolderlength = tempfolderpath.Length;
|
||||
|
||||
// Would be nice, but does not work :(
|
||||
@@ -605,9 +606,9 @@ namespace Duplicati.Library.AutoUpdater
|
||||
var paths = update.Files.Where(x => !x.Ignore).ToDictionary(x => x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar), Library.Utility.Utility.ClientFilenameStringComparer);
|
||||
paths.Add(manifest.Path, manifest);
|
||||
|
||||
var ignores = (from x in update.Files where x.Ignore select Library.Utility.Utility.AppendDirSeparator(x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar))).ToList();
|
||||
var ignores = (from x in update.Files where x.Ignore select Util.AppendDirSeparator(x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar))).ToList();
|
||||
|
||||
folder = Library.Utility.Utility.AppendDirSeparator(folder);
|
||||
folder = Util.AppendDirSeparator(folder);
|
||||
var baselen = folder.Length;
|
||||
|
||||
foreach (var file in Library.Utility.Utility.EnumerateFileSystemEntries(folder))
|
||||
@@ -718,7 +719,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
var localManifest = remoteManifest.Clone();
|
||||
localManifest.RemoteURLS = null;
|
||||
|
||||
inputfolder = Duplicati.Library.Utility.Utility.AppendDirSeparator(inputfolder);
|
||||
inputfolder = Util.AppendDirSeparator(inputfolder);
|
||||
var baselen = inputfolder.Length;
|
||||
var dirsep = System.IO.Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
|
||||
_userInfo.Domain = "";
|
||||
|
||||
_url = u.SetScheme("ftp").SetQuery(null).SetCredentials(null, null).ToString();
|
||||
_url = Duplicati.Library.Utility.Utility.AppendDirSeparator(_url, "/");
|
||||
_url = IO.Util.AppendDirSeparator(_url, "/");
|
||||
_listVerify = !CoreUtility.ParseBoolOption(options, "disable-upload-verify");
|
||||
|
||||
// Process the aftp-data-connection-type option
|
||||
|
||||
+4
@@ -72,6 +72,10 @@
|
||||
<Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
|
||||
<Name>Duplicati.Library.Utility</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -21,7 +21,8 @@ using Duplicati.Library.Interface;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend.AmazonCloudDrive
|
||||
{
|
||||
public class AmzCD : IBackend, IStreamingBackend, IRenameEnabledBackend
|
||||
@@ -72,7 +73,7 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive
|
||||
public AmzCD(string url, Dictionary<string, string> options)
|
||||
{
|
||||
var uri = new Utility.Uri(url);
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
m_path = Util.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
|
||||
if (options.ContainsKey(AUTHID_OPTION))
|
||||
m_authid = options[AUTHID_OPTION];
|
||||
|
||||
+4
@@ -58,6 +58,10 @@
|
||||
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
|
||||
<Name>Duplicati.Library.Interface</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Duplicati.Library.Utility;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
|
||||
@@ -56,7 +57,7 @@ namespace Duplicati.Library.Backend.Backblaze
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_bucketname = uri.Host;
|
||||
m_prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator("/" + uri.Path, "/");
|
||||
m_prefix = Util.AppendDirSeparator("/" + uri.Path, "/");
|
||||
|
||||
// For B2 we do not use a leading slash
|
||||
while(m_prefix.StartsWith("/", StringComparison.Ordinal))
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
|
||||
<Name>Duplicati.Library.Interface</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.IO;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
@@ -94,7 +95,7 @@ namespace Duplicati.Library.Backend.Box
|
||||
{
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
m_path = Util.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
|
||||
string authid = null;
|
||||
if (options.ContainsKey(AUTHID_OPTION))
|
||||
|
||||
@@ -62,6 +62,10 @@
|
||||
<Project>{D10A5FC0-11B4-4E70-86AA-8AEA52BD9798}</Project>
|
||||
<Name>Duplicati.Library.Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -22,7 +22,8 @@ using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Duplicati.Library.Interface;
|
||||
using System.Linq;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
public class FTP : IBackend, IStreamingBackend
|
||||
@@ -85,7 +86,7 @@ namespace Duplicati.Library.Backend
|
||||
m_userInfo.Domain = "";
|
||||
|
||||
m_url = u.SetScheme("ftp").SetQuery(null).SetCredentials(null, null).ToString();
|
||||
m_url = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_url, "/");
|
||||
m_url = Util.AppendDirSeparator(m_url, "/");
|
||||
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -297,14 +297,14 @@ namespace Duplicati.Library.Backend
|
||||
string root;
|
||||
if (Utility.Utility.IsClientLinux)
|
||||
{
|
||||
string path = Utility.Utility.AppendDirSeparator(System.IO.Path.GetFullPath(m_path));
|
||||
string path = Util.AppendDirSeparator(System.IO.Path.GetFullPath(m_path));
|
||||
root = "/";
|
||||
|
||||
//Find longest common prefix from mounted devices
|
||||
//TODO: Can trick this with symlinks, where the symlink is on one mounted volume,
|
||||
// and the actual storage is on another
|
||||
foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives())
|
||||
if (path.StartsWith(Utility.Utility.AppendDirSeparator(di.Name), StringComparison.Ordinal) && di.Name.Length > root.Length)
|
||||
if (path.StartsWith(Util.AppendDirSeparator(di.Name), StringComparison.Ordinal) && di.Name.Length > root.Length)
|
||||
root = di.Name;
|
||||
}
|
||||
else
|
||||
|
||||
+4
@@ -61,6 +61,10 @@
|
||||
<Project>{D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB}</Project>
|
||||
<Name>Duplicati.Library.OAuthHelper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -24,8 +24,7 @@ using Newtonsoft.Json;
|
||||
using Duplicati.Library.Backend.GoogleServices;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.Utility;
|
||||
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend.GoogleCloudStorage
|
||||
{
|
||||
@@ -54,7 +53,7 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_bucket = uri.Host;
|
||||
m_prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator("/" + uri.Path, "/");
|
||||
m_prefix = Util.AppendDirSeparator("/" + uri.Path, "/");
|
||||
|
||||
// For GCS we do not use a leading slash
|
||||
if (m_prefix.StartsWith("/", StringComparison.Ordinal))
|
||||
|
||||
@@ -25,6 +25,7 @@ using Newtonsoft.Json;
|
||||
using Duplicati.Library.Backend.GoogleServices;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.Utility;
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend.GoogleDrive
|
||||
{
|
||||
@@ -49,7 +50,7 @@ namespace Duplicati.Library.Backend.GoogleDrive
|
||||
{
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
m_path = Util.AppendDirSeparator(uri.HostAndPath, "/");
|
||||
|
||||
string authid = null;
|
||||
if (options.ContainsKey(AUTHID_OPTION))
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Duplicati.snk" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -20,6 +20,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
@@ -114,7 +115,7 @@ namespace Duplicati.Library.Backend
|
||||
m_path = u.HostAndPath; // Host and path of "jottacloud://folder/subfolder" is "folder/subfolder", so the actual folder path within the mount point.
|
||||
if (string.IsNullOrEmpty(m_path)) // Require a folder. Actually it is possible to store files directly on the root level of the mount point, but that does not seem to be a good option.
|
||||
throw new UserInformationException(Strings.Jottacloud.NoPathError, "JottaNoPath");
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_path, "/");
|
||||
m_path = Util.AppendDirSeparator(m_path, "/");
|
||||
if (!string.IsNullOrEmpty(u.Username))
|
||||
{
|
||||
m_userInfo = new System.Net.NetworkCredential();
|
||||
|
||||
@@ -81,6 +81,10 @@
|
||||
<Project>{D10A5FC0-11B4-4E70-86AA-8AEA52BD9798}</Project>
|
||||
<Name>Duplicati.Library.Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -4,7 +4,8 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
public class OneDrive : IBackend, IStreamingBackend, IQuotaEnabledBackend, IRenameEnabledBackend
|
||||
@@ -46,7 +47,7 @@ namespace Duplicati.Library.Backend
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_rootfolder = uri.Host;
|
||||
m_prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator("/" + uri.Path, "/");
|
||||
m_prefix = Util.AppendDirSeparator("/" + uri.Path, "/");
|
||||
|
||||
string authid = null;
|
||||
if (options.ContainsKey(AUTHID_OPTION))
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
<Project>{D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB}</Project>
|
||||
<Name>Duplicati.Library.OAuthHelper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -25,7 +25,8 @@ using Newtonsoft.Json.Converters;
|
||||
using Duplicati.Library.Strings;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend.OpenStack
|
||||
{
|
||||
public class OpenStackStorage : IBackend, IStreamingBackend
|
||||
@@ -319,7 +320,7 @@ namespace Duplicati.Library.Backend.OpenStack
|
||||
var uri = new Utility.Uri(url);
|
||||
|
||||
m_container = uri.Host;
|
||||
m_prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator("/" + uri.Path, "/");
|
||||
m_prefix = Util.AppendDirSeparator("/" + uri.Path, "/");
|
||||
|
||||
// For OpenStack we do not use a leading slash
|
||||
if (m_prefix.StartsWith("/", StringComparison.Ordinal))
|
||||
|
||||
@@ -72,6 +72,10 @@
|
||||
<Project>{D10A5FC0-11B4-4E70-86AA-8AEA52BD9798}</Project>
|
||||
<Name>Duplicati.Library.Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -23,7 +23,8 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
public class S3 : IBackend, IStreamingBackend, IRenameEnabledBackend
|
||||
@@ -259,7 +260,7 @@ namespace Duplicati.Library.Backend
|
||||
m_prefix = m_prefix.Trim();
|
||||
if (m_prefix.Length != 0)
|
||||
{
|
||||
m_prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_prefix, "/");
|
||||
m_prefix = Util.AppendDirSeparator(m_prefix, "/");
|
||||
}
|
||||
|
||||
// Auto-disable dns lookup for non AWS configurations
|
||||
|
||||
@@ -62,6 +62,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Duplicati.snk" />
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.IO;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
@@ -80,7 +81,7 @@ namespace Duplicati.Library.Backend
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_path))
|
||||
{
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_path, "/");
|
||||
m_path = Util.AppendDirSeparator(m_path, "/");
|
||||
}
|
||||
|
||||
if (!m_path.StartsWith("/", StringComparison.Ordinal))
|
||||
@@ -293,7 +294,7 @@ namespace Duplicati.Library.Backend
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return;
|
||||
|
||||
string working_dir = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_con.WorkingDirectory, "/");
|
||||
string working_dir = Util.AppendDirSeparator(m_con.WorkingDirectory, "/");
|
||||
if (working_dir == path)
|
||||
return;
|
||||
|
||||
|
||||
@@ -76,6 +76,10 @@
|
||||
<Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
|
||||
<Name>Duplicati.Library.Utility</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -29,6 +29,7 @@ using Duplicati.Library.Interface;
|
||||
|
||||
using SP = Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client; // Plain 'using' for extension methods
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
@@ -169,7 +170,7 @@ namespace Duplicati.Library.Backend
|
||||
m_serverRelPath = u.Path;
|
||||
if (!m_serverRelPath.StartsWith("/", StringComparison.Ordinal))
|
||||
m_serverRelPath = "/" + m_serverRelPath;
|
||||
m_serverRelPath = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_serverRelPath, "/");
|
||||
m_serverRelPath = Util.AppendDirSeparator(m_serverRelPath, "/");
|
||||
// remove marker for SP-Web
|
||||
m_serverRelPath = m_serverRelPath.Replace("//", "/");
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -24,7 +24,8 @@ using Duplicati.Library.Interface;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Linq;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
public class TahoeBackend : IBackend, IStreamingBackend
|
||||
@@ -105,7 +106,7 @@ namespace Duplicati.Library.Backend
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl");
|
||||
|
||||
m_url = u.SetScheme(m_useSSL ? "https" : "http").SetQuery(null).SetCredentials(null, null).ToString();
|
||||
m_url = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_url, "/");
|
||||
m_url = Util.AppendDirSeparator(m_url, "/");
|
||||
}
|
||||
|
||||
private System.Net.HttpWebRequest CreateRequest(string remotename, string queryparams)
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -21,7 +21,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Backend
|
||||
{
|
||||
public class WEBDAV : IBackend, IStreamingBackend
|
||||
@@ -93,12 +94,12 @@ namespace Duplicati.Library.Backend
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl");
|
||||
|
||||
m_url = u.SetScheme(m_useSSL ? "https" : "http").SetCredentials(null, null).SetQuery(null).ToString();
|
||||
m_url = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_url, "/");
|
||||
m_url = Util.AppendDirSeparator(m_url, "/");
|
||||
|
||||
m_path = u.Path;
|
||||
if (!m_path.StartsWith("/", StringComparison.Ordinal))
|
||||
m_path = "/" + m_path;
|
||||
m_path = Duplicati.Library.Utility.Utility.AppendDirSeparator(m_path, "/");
|
||||
m_path = Util.AppendDirSeparator(m_path, "/");
|
||||
|
||||
m_path = Library.Utility.Uri.UrlDecode(m_path);
|
||||
m_rawurl = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path).ToString();
|
||||
|
||||
@@ -70,6 +70,10 @@
|
||||
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
|
||||
<Name>Duplicati.Library.Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -24,7 +24,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Compression
|
||||
{
|
||||
/// <summary>
|
||||
@@ -41,7 +42,7 @@ namespace Duplicati.Library.Compression
|
||||
/// <param name="basefolder">The folder to base the archive on</param>
|
||||
public FileArchiveDirectory(string basefolder)
|
||||
{
|
||||
m_folder = Utility.Utility.AppendDirSeparator(basefolder);
|
||||
m_folder = Util.AppendDirSeparator(basefolder);
|
||||
}
|
||||
|
||||
#region IFileArchive Members
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2018, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Duplicati.Library.IO
|
||||
{
|
||||
public static class Util
|
||||
{
|
||||
/// <summary>
|
||||
/// A cached instance of the directory separator as a string
|
||||
/// </summary>
|
||||
public static readonly string DirectorySeparatorString = Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Appends the appropriate directory separator to paths, depending on OS.
|
||||
/// Does not append the separator if the path already ends with it.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to append to</param>
|
||||
/// <returns>The path with the directory separator appended</returns>
|
||||
public static string AppendDirSeparator(string path)
|
||||
{
|
||||
return AppendDirSeparator(path, DirectorySeparatorString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the specified directory separator to paths.
|
||||
/// Does not append the separator if the path already ends with it.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to append to</param>
|
||||
/// <param name="separator">The directory separator to use</param>
|
||||
/// <returns>The path with the directory separator appended</returns>
|
||||
public static string AppendDirSeparator(string path, string separator)
|
||||
{
|
||||
return !path.EndsWith(separator, StringComparison.Ordinal) ? path + separator : path;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Guesses the directory separator from the path
|
||||
/// </summary>
|
||||
/// <param name="path">The path to guess the separator from</param>
|
||||
/// <returns>The guessed directory separator</returns>
|
||||
public static string GuessDirSeparator(string path)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(path) || path.StartsWith("/", StringComparison.Ordinal) ? "/" : "\\";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -23,7 +23,8 @@ using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Duplicati.Library.Utility;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Main
|
||||
{
|
||||
public class Controller : IDisposable
|
||||
@@ -898,7 +899,7 @@ namespace Duplicati.Library.Main
|
||||
foundAnyPaths = true;
|
||||
|
||||
if (!fi.Exists)
|
||||
source = Library.Utility.Utility.AppendDirSeparator(source);
|
||||
source = Util.AppendDirSeparator(source);
|
||||
|
||||
sources.Add(source);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2013, The Duplicati Team
|
||||
// Copyright (C) 2013, The Duplicati Team
|
||||
|
||||
// http://www.duplicati.com, opensource@duplicati.com
|
||||
//
|
||||
@@ -16,7 +16,8 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
using System;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Main.Database
|
||||
{
|
||||
internal class LocalBugReportDatabase : LocalDatabase
|
||||
@@ -46,7 +47,7 @@ namespace Duplicati.Library.Main.Database
|
||||
upcmd.Transaction = tr;
|
||||
upcmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""ID"" INTEGER PRIMARY KEY, ""RealPath"" TEXT NOT NULL, ""Obfuscated"" TEXT NULL)", tablename));
|
||||
upcmd.ExecuteNonQuery(string.Format(@"INSERT INTO ""{0}"" (""RealPath"") SELECT DISTINCT ""Path"" FROM ""File"" ORDER BY ""Path"" ", tablename));
|
||||
upcmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Obfuscated"" = ? || length(""RealPath"") || ? || ""ID"" || (CASE WHEN substr(""RealPath"", length(""RealPath"")) = ? THEN ? ELSE ? END) ", tablename), Library.Utility.Utility.IsClientLinux ? "/" : "X:\\", Library.Utility.Utility.DirectorySeparatorString, Library.Utility.Utility.DirectorySeparatorString, Library.Utility.Utility.DirectorySeparatorString, ".bin");
|
||||
upcmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Obfuscated"" = ? || length(""RealPath"") || ? || ""ID"" || (CASE WHEN substr(""RealPath"", length(""RealPath"")) = ? THEN ? ELSE ? END) ", tablename), Library.Utility.Utility.IsClientLinux ? "/" : "X:\\", Util.DirectorySeparatorString, Util.DirectorySeparatorString, Util.DirectorySeparatorString, ".bin");
|
||||
|
||||
/*long id = 1;
|
||||
using(var rd = cmd.ExecuteReader(string.Format(@"SELECT ""RealPath"", ""Obfuscated"" FROM ""{0}"" ", tablename)))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -19,7 +19,8 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Main.Database
|
||||
{
|
||||
internal class LocalListDatabase : LocalDatabase
|
||||
@@ -148,7 +149,7 @@ namespace Duplicati.Library.Main.Database
|
||||
if (v0 != null)
|
||||
maxpath = v0.ToString();
|
||||
|
||||
var dirsep = Duplicati.Library.Utility.Utility.GuessDirSeparator(maxpath);
|
||||
var dirsep = Util.GuessDirSeparator(maxpath);
|
||||
|
||||
cmd.CommandText = string.Format(@"SELECT COUNT(*) FROM ""{0}""", tmpnames.Tablename);
|
||||
var filecount = cmd.ExecuteScalarInt64(0);
|
||||
@@ -161,7 +162,7 @@ namespace Duplicati.Library.Main.Database
|
||||
|
||||
while (filecount != foundfiles && maxpath.Length > 0)
|
||||
{
|
||||
var mp = Duplicati.Library.Utility.Utility.AppendDirSeparator(maxpath, dirsep);
|
||||
var mp = Util.AppendDirSeparator(maxpath, dirsep);
|
||||
cmd.SetParameterValue(0, mp.Length);
|
||||
cmd.SetParameterValue(1, mp);
|
||||
foundfiles = cmd.ExecuteScalarInt64(0);
|
||||
@@ -185,7 +186,7 @@ namespace Duplicati.Library.Main.Database
|
||||
|
||||
return
|
||||
new IFileversion[] {
|
||||
new FileversionFixed() { Path = maxpath == "" ? "" : Duplicati.Library.Utility.Utility.AppendDirSeparator(maxpath, dirsep) }
|
||||
new FileversionFixed() { Path = maxpath == "" ? "" : Util.AppendDirSeparator(maxpath, dirsep) }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -194,7 +195,7 @@ namespace Duplicati.Library.Main.Database
|
||||
private IEnumerable<string> SelectFolderEntries(System.Data.IDbCommand cmd, string prefix, string table)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(prefix))
|
||||
prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator(prefix, Duplicati.Library.Utility.Utility.GuessDirSeparator(prefix));
|
||||
prefix = Util.AppendDirSeparator(prefix, Util.GuessDirSeparator(prefix));
|
||||
|
||||
var ppl = prefix.Length;
|
||||
using(var rd = cmd.ExecuteReader(string.Format(@"SELECT DISTINCT ""Path"" FROM ""{0}"" ", table)))
|
||||
@@ -204,7 +205,7 @@ namespace Duplicati.Library.Main.Database
|
||||
if (!s.StartsWith(prefix, StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
var dirsep = Duplicati.Library.Utility.Utility.GuessDirSeparator(s);
|
||||
var dirsep = Util.GuessDirSeparator(s);
|
||||
|
||||
s = s.Substring(ppl);
|
||||
var ix = s.IndexOf(dirsep, StringComparison.Ordinal);
|
||||
@@ -227,10 +228,10 @@ namespace Duplicati.Library.Main.Database
|
||||
else
|
||||
pathprefix = ((Library.Utility.FilterExpression)filter).GetSimpleList().First();
|
||||
|
||||
var dirsep = Duplicati.Library.Utility.Utility.GuessDirSeparator(pathprefix);
|
||||
var dirsep = Util.GuessDirSeparator(pathprefix);
|
||||
|
||||
if (pathprefix.Length > 0 || dirsep == "/")
|
||||
pathprefix = Duplicati.Library.Utility.Utility.AppendDirSeparator(pathprefix, dirsep);
|
||||
pathprefix = Util.AppendDirSeparator(pathprefix, dirsep);
|
||||
|
||||
using(var tmpnames = new FilteredFilenameTable(m_connection, new Library.Utility.FilterExpression(new string[] { pathprefix + "*" }, true), null))
|
||||
using(var cmd = m_connection.CreateCommand())
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Duplicati.Library.IO;
|
||||
using Duplicati.Library.Main.Volumes;
|
||||
|
||||
namespace Duplicati.Library.Main.Database
|
||||
@@ -343,7 +344,7 @@ namespace Duplicati.Library.Main.Database
|
||||
if (v0 != null && v0 != DBNull.Value)
|
||||
maxpath = v0.ToString();
|
||||
|
||||
var dirsep = Duplicati.Library.Utility.Utility.GuessDirSeparator(maxpath);
|
||||
var dirsep = Util.GuessDirSeparator(maxpath);
|
||||
|
||||
cmd.CommandText = string.Format(@"SELECT COUNT(*) FROM ""{0}""", m_tempfiletable);
|
||||
var filecount = cmd.ExecuteScalarInt64(-1);
|
||||
@@ -356,7 +357,7 @@ namespace Duplicati.Library.Main.Database
|
||||
|
||||
while (filecount != foundfiles && maxpath.Length > 0)
|
||||
{
|
||||
var mp = Library.Utility.Utility.AppendDirSeparator(maxpath, dirsep);
|
||||
var mp = Util.AppendDirSeparator(maxpath, dirsep);
|
||||
cmd.SetParameterValue(0, mp.Length);
|
||||
cmd.SetParameterValue(1, mp);
|
||||
foundfiles = cmd.ExecuteScalarInt64(-1);
|
||||
@@ -372,13 +373,13 @@ namespace Duplicati.Library.Main.Database
|
||||
}
|
||||
}
|
||||
|
||||
return maxpath == "" ? "" : Library.Utility.Utility.AppendDirSeparator(maxpath, dirsep);
|
||||
return maxpath == "" ? "" : Util.AppendDirSeparator(maxpath, dirsep);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTargetPaths(string largest_prefix, string destination)
|
||||
{
|
||||
var dirsep = Duplicati.Library.Utility.Utility.GuessDirSeparator(string.IsNullOrWhiteSpace(largest_prefix) ? GetFirstPath() : largest_prefix);
|
||||
var dirsep = Util.GuessDirSeparator(string.IsNullOrWhiteSpace(largest_prefix) ? GetFirstPath() : largest_prefix);
|
||||
|
||||
using(var cmd = m_connection.CreateCommand())
|
||||
{
|
||||
@@ -398,7 +399,7 @@ namespace Duplicati.Library.Main.Database
|
||||
else if (Library.Utility.Utility.IsClientWindows && dirsep == "/")
|
||||
{
|
||||
// For Linux -> Win, we use the temporary folder's drive as the root path
|
||||
cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Targetpath"" = CASE WHEN SUBSTR(""Path"", 1, 1) == ""/"" THEN ? || SUBSTR(""Path"", 2) ELSE ""Path"" END", m_tempfiletable), Library.Utility.Utility.AppendDirSeparator(System.IO.Path.GetPathRoot(Library.Utility.TempFolder.SystemTempPath)).Replace("\\", "/"));
|
||||
cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Targetpath"" = CASE WHEN SUBSTR(""Path"", 1, 1) == ""/"" THEN ? || SUBSTR(""Path"", 2) ELSE ""Path"" END", m_tempfiletable), Util.AppendDirSeparator(System.IO.Path.GetPathRoot(Library.Utility.TempFolder.SystemTempPath)).Replace("\\", "/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,7 +421,7 @@ namespace Duplicati.Library.Main.Database
|
||||
}
|
||||
else
|
||||
{
|
||||
largest_prefix = Library.Utility.Utility.AppendDirSeparator(largest_prefix, dirsep);
|
||||
largest_prefix = Util.AppendDirSeparator(largest_prefix, dirsep);
|
||||
cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = SUBSTR(""Path"", ?)", m_tempfiletable), largest_prefix.Length + 1);
|
||||
}
|
||||
}
|
||||
@@ -438,7 +439,7 @@ namespace Duplicati.Library.Main.Database
|
||||
// Paths are now relative with target-os naming system
|
||||
// so we prefix them with the target path
|
||||
|
||||
cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = ? || ""TargetPath"" ", m_tempfiletable), Library.Utility.Utility.AppendDirSeparator(destination));
|
||||
cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = ? || ""TargetPath"" ", m_tempfiletable), Util.AppendDirSeparator(destination));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2013, The Duplicati Team
|
||||
// Copyright (C) 2013, The Duplicati Team
|
||||
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -19,7 +19,8 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Main.Database
|
||||
{
|
||||
public class PathLookupHelper<T>
|
||||
@@ -107,7 +108,7 @@ namespace Duplicati.Library.Main.Database
|
||||
else if (m_lookup != null)
|
||||
{
|
||||
//Maintain the hotpath lookup information
|
||||
prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator(System.IO.Path.Combine(prefix, p));
|
||||
prefix = Util.AppendDirSeparator(System.IO.Path.Combine(prefix, p));
|
||||
m_lookup.Add(new KeyValuePair<string, FolderEntry>(prefix, cur));
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ namespace Duplicati.Library.Main.Database
|
||||
if (m_lookup != null)
|
||||
{
|
||||
//Maintain the hotpath lookup information
|
||||
prefix = Duplicati.Library.Utility.Utility.AppendDirSeparator(System.IO.Path.Combine(prefix, p));
|
||||
prefix = Util.AppendDirSeparator(System.IO.Path.Combine(prefix, p));
|
||||
m_lookup.Add(new KeyValuePair<string, FolderEntry>(prefix, cur));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ using CoCoL;
|
||||
using System.Threading;
|
||||
using Duplicati.Library.Snapshots;
|
||||
using Duplicati.Library.Utility;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Main.Operation
|
||||
{
|
||||
/// <summary>
|
||||
@@ -376,7 +377,7 @@ namespace Duplicati.Library.Main.Operation
|
||||
Utility.VerifyParameters(m_database, m_options);
|
||||
|
||||
var probe_path = m_database.GetFirstPath();
|
||||
if (probe_path != null && Duplicati.Library.Utility.Utility.GuessDirSeparator(probe_path) != System.IO.Path.DirectorySeparatorChar.ToString())
|
||||
if (probe_path != null && Util.GuessDirSeparator(probe_path) != System.IO.Path.DirectorySeparatorChar.ToString())
|
||||
throw new UserInformationException(string.Format("The backup contains files that belong to another operating system. Proceeding with a backup would cause the database to contain paths from two different operation systems, which is not supported. To proceed without losing remote data, delete all filesets and make sure the --{0} option is set, then run the backup again to re-use the existing data on the remote store.", "no-auto-compact"), "CrossOsDatabaseReuseNotSupported");
|
||||
|
||||
if (m_database.PartiallyRecreated)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -754,10 +754,10 @@ namespace Duplicati.Library.Main.Operation
|
||||
// Find the largest common prefix
|
||||
var largest_prefix = options.DontCompressRestorePaths ? "" : database.GetLargestPrefix();
|
||||
|
||||
Logging.Log.WriteVerboseMessage(LOGTAG, "MappingRestorePath", "Mapping restore path prefix to \"{0}\" to \"{1}\"", largest_prefix, Library.Utility.Utility.AppendDirSeparator(options.Restorepath));
|
||||
Logging.Log.WriteVerboseMessage(LOGTAG, "MappingRestorePath", "Mapping restore path prefix to \"{0}\" to \"{1}\"", largest_prefix, Util.AppendDirSeparator(options.Restorepath));
|
||||
|
||||
// Set the target paths, special care with C:\ and /
|
||||
database.SetTargetPaths(largest_prefix, Library.Utility.Utility.AppendDirSeparator(options.Restorepath));
|
||||
database.SetTargetPaths(largest_prefix, Util.AppendDirSeparator(options.Restorepath));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -48,18 +48,11 @@
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="AlphaVSS.Common">
|
||||
<HintPath>..\..\..\packages\AlphaVSS.1.4.0\lib\net45\AlphaVSS.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlphaFS">
|
||||
<HintPath>..\..\..\packages\AlphaFS.2.1.3\lib\net45\AlphaFS.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DefineDosDevice.cs" />
|
||||
<Compile Include="MSSQLUtility.cs" />
|
||||
<Compile Include="HyperVUtility.cs" />
|
||||
<Compile Include="ISnapshotService.cs" />
|
||||
@@ -72,7 +65,6 @@
|
||||
<Compile Include="USNJournal.cs" />
|
||||
<Compile Include="Win32USN.cs" />
|
||||
<Compile Include="WindowsSnapshot.cs" />
|
||||
<Compile Include="WinNativeMethods.cs" />
|
||||
<Compile Include="NoSnapshotLinux.cs" />
|
||||
<Compile Include="NoSnapshotWindows.cs" />
|
||||
<Compile Include="Strings.cs" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -94,7 +94,7 @@ namespace Duplicati.Library.Snapshots
|
||||
if (Utility.Utility.IsClientLinux)
|
||||
throw new Interface.UserInformationException(Strings.USNHelper.LinuxNotSupportedError, "UsnOnLinuxNotSupported");
|
||||
|
||||
m_volume = Utility.Utility.AppendDirSeparator(volumeRoot);
|
||||
m_volume = Util.AppendDirSeparator(volumeRoot);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace Duplicati.Library.Snapshots
|
||||
/// <returns>A list of tuples with changed files and folders and their type</returns>
|
||||
public IEnumerable<Tuple<string, EntryType>> GetChangedFileSystemEntries(string sourceFileOrFolder, long minUsn, ChangeReason reason)
|
||||
{
|
||||
var isFolder = sourceFileOrFolder.EndsWith(Utility.Utility.DirectorySeparatorString, StringComparison.Ordinal);
|
||||
var isFolder = sourceFileOrFolder.EndsWith(Util.DirectorySeparatorString, StringComparison.Ordinal);
|
||||
|
||||
foreach (var r in GetRecords(minUsn))
|
||||
{
|
||||
@@ -499,7 +499,7 @@ namespace Duplicati.Library.Snapshots
|
||||
|
||||
if (rec.UsnRecord.FileAttributes.HasFlag(Win32USN.FileAttributes.Directory))
|
||||
{
|
||||
path = Utility.Utility.AppendDirSeparator(path);
|
||||
path = Util.AppendDirSeparator(path);
|
||||
}
|
||||
|
||||
// set resolved path
|
||||
|
||||
@@ -25,6 +25,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Duplicati.Library.Interface;
|
||||
using Duplicati.Library.IO;
|
||||
using Duplicati.Library.Utility;
|
||||
|
||||
namespace Duplicati.Library.Snapshots
|
||||
@@ -124,7 +125,7 @@ namespace Duplicati.Library.Snapshots
|
||||
}
|
||||
else
|
||||
{
|
||||
changedFolders.Add(Utility.Utility.AppendDirSeparator(entry.Item1));
|
||||
changedFolders.Add(Util.AppendDirSeparator(entry.Item1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +161,7 @@ namespace Duplicati.Library.Snapshots
|
||||
// use original sources
|
||||
foreach (var path in volumeSources)
|
||||
{
|
||||
var isFolder = path.EndsWith(Utility.Utility.DirectorySeparatorString, StringComparison.Ordinal);
|
||||
var isFolder = path.EndsWith(Util.DirectorySeparatorString, StringComparison.Ordinal);
|
||||
if (isFolder)
|
||||
{
|
||||
volumeData.Folders.Add(path);
|
||||
|
||||
@@ -109,6 +109,10 @@
|
||||
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
|
||||
<Name>Duplicati.Library.Interface</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -17,6 +17,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Duplicati.Library.IO;
|
||||
using Duplicati.Library.Localization.Short;
|
||||
|
||||
namespace Duplicati.Library.Utility
|
||||
@@ -356,7 +357,7 @@ namespace Duplicati.Library.Utility
|
||||
yield return windir;
|
||||
|
||||
// Also exclude "C:\Windows.old\"
|
||||
yield return Utility.AppendDirSeparator(windir.TrimEnd('\\', '/') + ".old");
|
||||
yield return Util.AppendDirSeparator(windir.TrimEnd('\\', '/') + ".old");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +582,7 @@ namespace Duplicati.Library.Utility
|
||||
// Meaning a filter for 'C:\Windows' won't match 'C:\Windows\'.
|
||||
// So this makes sure special folder's filter's have a trailing directory separator.
|
||||
// (Alternatively, this could append '*' to all folder filters.)
|
||||
return Utility.AppendDirSeparator(filter);
|
||||
return Util.AppendDirSeparator(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -18,7 +18,8 @@
|
||||
//
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Utility
|
||||
{
|
||||
/// <summary>
|
||||
@@ -37,7 +38,7 @@ namespace Duplicati.Library.Utility
|
||||
public TempFolder(string folder)
|
||||
{
|
||||
m_protect = false;
|
||||
m_folder = Utility.AppendDirSeparator(folder);
|
||||
m_folder = Util.AppendDirSeparator(folder);
|
||||
System.IO.Directory.CreateDirectory(m_folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Library.Utility
|
||||
{
|
||||
public static class Utility
|
||||
@@ -162,7 +163,7 @@ namespace Duplicati.Library.Utility
|
||||
/// <returns>A list of the full filenames</returns>
|
||||
public static IEnumerable<string> EnumerateFiles(string basepath, IFilter filter)
|
||||
{
|
||||
return EnumerateFileSystemEntries(basepath, filter).Where(x => !x.EndsWith(DirectorySeparatorString, StringComparison.Ordinal));
|
||||
return EnumerateFileSystemEntries(basepath, filter).Where(x => !x.EndsWith(Util.DirectorySeparatorString, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,7 +175,7 @@ namespace Duplicati.Library.Utility
|
||||
/// <returns>A list of the full paths</returns>
|
||||
public static IEnumerable<string> EnumerateFolders(string basepath, IFilter filter)
|
||||
{
|
||||
return EnumerateFileSystemEntries(basepath, filter).Where(x => x.EndsWith(DirectorySeparatorString, StringComparison.Ordinal));
|
||||
return EnumerateFileSystemEntries(basepath, filter).Where(x => x.EndsWith(Util.DirectorySeparatorString, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -260,7 +261,7 @@ namespace Duplicati.Library.Utility
|
||||
|
||||
if (IsFolder(rootpath, attributeReader))
|
||||
{
|
||||
rootpath = AppendDirSeparator(rootpath);
|
||||
rootpath = Util.AppendDirSeparator(rootpath);
|
||||
try
|
||||
{
|
||||
|
||||
@@ -280,7 +281,7 @@ namespace Duplicati.Library.Utility
|
||||
|
||||
while (lst.Count > 0)
|
||||
{
|
||||
var f = AppendDirSeparator(lst.Pop());
|
||||
var f = Util.AppendDirSeparator(lst.Pop());
|
||||
|
||||
yield return f;
|
||||
|
||||
@@ -288,7 +289,7 @@ namespace Duplicati.Library.Utility
|
||||
{
|
||||
foreach (var s in folderList(f))
|
||||
{
|
||||
var sf = AppendDirSeparator(s);
|
||||
var sf = Util.AppendDirSeparator(s);
|
||||
try
|
||||
{
|
||||
var attr = attributeReader?.Invoke(sf) ?? FileAttributes.Directory;
|
||||
@@ -412,7 +413,7 @@ namespace Duplicati.Library.Utility
|
||||
/// (note that this returns false if the two argument paths are identical!)</returns>
|
||||
public static bool IsPathBelowFolder(string fileOrFolderPath, string parentFolder)
|
||||
{
|
||||
var sanitizedParentFolder = AppendDirSeparator(parentFolder);
|
||||
var sanitizedParentFolder = Util.AppendDirSeparator(parentFolder);
|
||||
return fileOrFolderPath.StartsWith(sanitizedParentFolder, ClientFilenameStringComparison) &&
|
||||
!fileOrFolderPath.Equals(sanitizedParentFolder, ClientFilenameStringComparison);
|
||||
}
|
||||
@@ -434,9 +435,9 @@ namespace Duplicati.Library.Utility
|
||||
var last = path.LastIndexOf(Path.DirectorySeparatorChar, len);
|
||||
if (last == -1 || last == 0 && len == 0)
|
||||
return null;
|
||||
|
||||
|
||||
if (last == 0 && !IsClientWindows)
|
||||
return DirectorySeparatorString;
|
||||
return Util.DirectorySeparatorString;
|
||||
|
||||
var parent = path.Substring(0, last);
|
||||
|
||||
@@ -518,43 +519,6 @@ namespace Duplicati.Library.Utility
|
||||
return EnumerateFolders(folder, filter).Sum((path) => new FileInfo(path).Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A cached instance of the directory separator as a string
|
||||
/// </summary>
|
||||
public static readonly string DirectorySeparatorString = Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// Appends the appropriate directory separator to paths, depending on OS.
|
||||
/// Does not append the separator if the path already ends with it.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to append to</param>
|
||||
/// <returns>The path with the directory separator appended</returns>
|
||||
public static string AppendDirSeparator(string path)
|
||||
{
|
||||
return AppendDirSeparator(path, DirectorySeparatorString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the specified directory separator to paths.
|
||||
/// Does not append the separator if the path already ends with it.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to append to</param>
|
||||
/// <param name="separator">The directory separator to use</param>
|
||||
/// <returns>The path with the directory separator appended</returns>
|
||||
public static string AppendDirSeparator(string path, string separator)
|
||||
{
|
||||
return !path.EndsWith(separator, StringComparison.Ordinal) ? path + separator : path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guesses the directory separator from the path
|
||||
/// </summary>
|
||||
/// <param name="path">The path to guess the separator from</param>
|
||||
/// <returns>The guessed directory separator</returns>
|
||||
public static string GuessDirSeparator(string path)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(path) || path.StartsWith("/", StringComparison.Ordinal) ? "/" : "\\";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Some streams can return a number that is less than the requested number of bytes.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.Server
|
||||
{
|
||||
public class Program
|
||||
@@ -570,7 +571,7 @@ namespace Duplicati.Server
|
||||
#endif
|
||||
}
|
||||
else
|
||||
DataFolder = Library.Utility.Utility.AppendDirSeparator(Environment.ExpandEnvironmentVariables(serverDataFolder).Trim('"'));
|
||||
DataFolder = Util.AppendDirSeparator(Environment.ExpandEnvironmentVariables(serverDataFolder).Trim('"'));
|
||||
|
||||
var sqliteVersion = new Version((string)Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType.GetProperty("SQLiteVersion").GetValue(null, null));
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
|
||||
try
|
||||
{
|
||||
if (path != "" && path != "/")
|
||||
path = Duplicati.Library.Utility.Utility.AppendDirSeparator(path);
|
||||
path = Util.AppendDirSeparator(path);
|
||||
|
||||
IEnumerable<Serializable.TreeNode> res;
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
|
||||
var accessible = isFile || canAccess(s);
|
||||
var isLeaf = isFile || !accessible || isEmptyFolder(s);
|
||||
|
||||
var rawid = isFolder ? Library.Utility.Utility.AppendDirSeparator(s) : s;
|
||||
var rawid = isFolder ? Util.AppendDirSeparator(s) : s;
|
||||
if (skipFiles && !isFolder)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HttpServer.HttpModules;
|
||||
@@ -248,9 +248,9 @@ namespace Duplicati.Server.WebServer
|
||||
if (!string.IsNullOrWhiteSpace(userroot)
|
||||
&&
|
||||
(
|
||||
userroot.StartsWith(Library.Utility.Utility.AppendDirSeparator(System.Reflection.Assembly.GetExecutingAssembly().Location), Library.Utility.Utility.ClientFilenameStringComparison)
|
||||
userroot.StartsWith(Util.AppendDirSeparator(System.Reflection.Assembly.GetExecutingAssembly().Location), Library.Utility.Utility.ClientFilenameStringComparison)
|
||||
||
|
||||
userroot.StartsWith(Library.Utility.Utility.AppendDirSeparator(Program.StartupPath), Library.Utility.Utility.ClientFilenameStringComparison)
|
||||
userroot.StartsWith(Util.AppendDirSeparator(Program.StartupPath), Library.Utility.Utility.ClientFilenameStringComparison)
|
||||
)
|
||||
)
|
||||
#endif
|
||||
|
||||
@@ -176,6 +176,10 @@
|
||||
<Project>{5489181D-950C-44AF-873C-45EB0A3B6BD2}</Project>
|
||||
<Name>Duplicati.Library.Backend.GoogleServices</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Library\IO\Duplicati.Library.IO.csproj">
|
||||
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
|
||||
<Name>Duplicati.Library.IO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2015, The Duplicati Team
|
||||
// http://www.duplicati.com, info@duplicati.com
|
||||
//
|
||||
@@ -27,7 +27,8 @@ using System.Text;
|
||||
using Duplicati.Library.Logging;
|
||||
using Duplicati.Library.Utility;
|
||||
using System.Linq;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.UnitTest
|
||||
{
|
||||
/// <summary>
|
||||
@@ -305,12 +306,12 @@ namespace Duplicati.UnitTest
|
||||
if (!f.StartsWith(usingFHWithRestore ? fhtempsource : folders[i], Utility.ClientFilenameStringComparison))
|
||||
throw new Exception(string.Format("Unexpected file found: {0}, path is not a subfolder for {1}", f, folders[i]));
|
||||
|
||||
f = f.Substring(Utility.AppendDirSeparator(usingFHWithRestore ? fhtempsource : folders[i]).Length);
|
||||
f = f.Substring(Util.AppendDirSeparator(usingFHWithRestore ? fhtempsource : folders[i]).Length);
|
||||
|
||||
do
|
||||
{
|
||||
f = System.IO.Path.GetDirectoryName(f);
|
||||
partialFolders[Utility.AppendDirSeparator(f)] = null;
|
||||
partialFolders[Util.AppendDirSeparator(f)] = null;
|
||||
} while (f.IndexOf(System.IO.Path.DirectorySeparatorChar) > 0);
|
||||
}
|
||||
|
||||
@@ -321,11 +322,11 @@ namespace Duplicati.UnitTest
|
||||
|
||||
List<string> filterlist;
|
||||
|
||||
var tfe = Utility.AppendDirSeparator(usingFHWithRestore ? fhtempsource : folders[i]);
|
||||
var tfe = Util.AppendDirSeparator(usingFHWithRestore ? fhtempsource : folders[i]);
|
||||
|
||||
filterlist = (from n in partialFolders.Keys
|
||||
where !string.IsNullOrWhiteSpace(n) && n != System.IO.Path.DirectorySeparatorChar.ToString()
|
||||
select Utility.AppendDirSeparator(System.IO.Path.Combine(tfe, n)))
|
||||
select Util.AppendDirSeparator(System.IO.Path.Combine(tfe, n)))
|
||||
.Union(testfiles) //Add files with full path
|
||||
.Union(new string[] { tfe }) //Ensure root folder is included
|
||||
.Distinct()
|
||||
@@ -367,7 +368,7 @@ namespace Duplicati.UnitTest
|
||||
continue;
|
||||
if (s == logfilename)
|
||||
continue;
|
||||
if (s.StartsWith(Utility.AppendDirSeparator(tf), StringComparison.Ordinal))
|
||||
if (s.StartsWith(Util.AppendDirSeparator(tf), StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
Log.WriteWarningMessage(LOGTAG, "LeftOverTempFile", null, "Found left-over temp file: {0}", s.Substring(tempdir.Length));
|
||||
@@ -381,7 +382,7 @@ namespace Duplicati.UnitTest
|
||||
}
|
||||
|
||||
foreach (string s in Utility.EnumerateFolders(tempdir))
|
||||
if (!s.StartsWith(Utility.AppendDirSeparator(tf), StringComparison.Ordinal) && Utility.AppendDirSeparator(s) != Utility.AppendDirSeparator(tf) && Utility.AppendDirSeparator(s) != Utility.AppendDirSeparator(tempdir))
|
||||
if (!s.StartsWith(Util.AppendDirSeparator(tf), StringComparison.Ordinal) && Util.AppendDirSeparator(s) != Util.AppendDirSeparator(tf) && Util.AppendDirSeparator(s) != Util.AppendDirSeparator(tempdir))
|
||||
{
|
||||
Log.WriteWarningMessage(LOGTAG, "LeftOverTempFolder", null, "Found left-over temp folder: {0}", s.Substring(tempdir.Length));
|
||||
BasicSetupHelper.ProgressWriteLine("Found left-over temp folder: {0}", s.Substring(tempdir.Length));
|
||||
|
||||
@@ -21,7 +21,8 @@ using Duplicati.Library.Utility;
|
||||
using System.Linq;
|
||||
using Duplicati.Library.Logging;
|
||||
using System.Reflection;
|
||||
|
||||
using Duplicati.Library.IO;
|
||||
|
||||
namespace Duplicati.UnitTest
|
||||
{
|
||||
public static class TestUtils
|
||||
@@ -68,7 +69,7 @@ namespace Duplicati.UnitTest
|
||||
/// <param name="targetfolder">Destination directory path</param>
|
||||
public static void CopyDirectoryRecursive(string sourcefolder, string targetfolder)
|
||||
{
|
||||
sourcefolder = Library.Utility.Utility.AppendDirSeparator(sourcefolder);
|
||||
sourcefolder = Util.AppendDirSeparator(sourcefolder);
|
||||
|
||||
var work = new Queue<string>();
|
||||
work.Enqueue(sourcefolder);
|
||||
@@ -150,8 +151,8 @@ namespace Duplicati.UnitTest
|
||||
public static void VerifyDir(string f1, string f2, bool verifymetadata)
|
||||
{
|
||||
var anymissing = false;
|
||||
f1 = Utility.AppendDirSeparator(f1);
|
||||
f2 = Utility.AppendDirSeparator(f2);
|
||||
f1 = Util.AppendDirSeparator(f1);
|
||||
f2 = Util.AppendDirSeparator(f2);
|
||||
|
||||
var folders1 = Utility.EnumerateFolders(f1);
|
||||
var folders2 = Utility.EnumerateFolders(f2).ToList();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
using Duplicati.Library.Utility;
|
||||
using Duplicati.Library.IO;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -29,26 +30,26 @@ namespace Duplicati.UnitTest
|
||||
public static void AppendDirSeparator()
|
||||
{
|
||||
const string noTrailingSlash = @"/a\b/c";
|
||||
string hasTrailingSlash = noTrailingSlash + Utility.DirectorySeparatorString;
|
||||
string hasTrailingSlash = noTrailingSlash + Util.DirectorySeparatorString;
|
||||
|
||||
string alternateSeparator = null;
|
||||
if (String.Equals(Utility.DirectorySeparatorString, "/", StringComparison.Ordinal))
|
||||
if (String.Equals(Util.DirectorySeparatorString, "/", StringComparison.Ordinal))
|
||||
{
|
||||
alternateSeparator = @"\";
|
||||
}
|
||||
if (String.Equals(Utility.DirectorySeparatorString, @"\", StringComparison.Ordinal))
|
||||
if (String.Equals(Util.DirectorySeparatorString, @"\", StringComparison.Ordinal))
|
||||
{
|
||||
alternateSeparator = "/";
|
||||
}
|
||||
|
||||
Assert.AreEqual(hasTrailingSlash, Utility.AppendDirSeparator(noTrailingSlash));
|
||||
Assert.AreEqual(hasTrailingSlash, Utility.AppendDirSeparator(hasTrailingSlash));
|
||||
Assert.AreEqual(hasTrailingSlash, Utility.AppendDirSeparator(noTrailingSlash), Utility.DirectorySeparatorString);
|
||||
Assert.AreEqual(hasTrailingSlash, Utility.AppendDirSeparator(hasTrailingSlash), Utility.DirectorySeparatorString);
|
||||
Assert.AreEqual(hasTrailingSlash, Util.AppendDirSeparator(noTrailingSlash));
|
||||
Assert.AreEqual(hasTrailingSlash, Util.AppendDirSeparator(hasTrailingSlash));
|
||||
Assert.AreEqual(hasTrailingSlash, Util.AppendDirSeparator(noTrailingSlash), Util.DirectorySeparatorString);
|
||||
Assert.AreEqual(hasTrailingSlash, Util.AppendDirSeparator(hasTrailingSlash), Util.DirectorySeparatorString);
|
||||
|
||||
Assert.AreEqual(noTrailingSlash + alternateSeparator, Utility.AppendDirSeparator(noTrailingSlash, alternateSeparator));
|
||||
Assert.AreEqual(noTrailingSlash + alternateSeparator, Utility.AppendDirSeparator(noTrailingSlash + alternateSeparator, alternateSeparator));
|
||||
Assert.AreEqual(hasTrailingSlash + alternateSeparator, Utility.AppendDirSeparator(hasTrailingSlash, alternateSeparator));
|
||||
Assert.AreEqual(noTrailingSlash + alternateSeparator, Util.AppendDirSeparator(noTrailingSlash, alternateSeparator));
|
||||
Assert.AreEqual(noTrailingSlash + alternateSeparator, Util.AppendDirSeparator(noTrailingSlash + alternateSeparator, alternateSeparator));
|
||||
Assert.AreEqual(hasTrailingSlash + alternateSeparator, Util.AppendDirSeparator(hasTrailingSlash, alternateSeparator));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user