diff --git a/Duplicati/CommandLine/Help.cs b/Duplicati/CommandLine/Help.cs index 7bf5b07ee..5baa0858f 100644 --- a/Duplicati/CommandLine/Help.cs +++ b/Duplicati/CommandLine/Help.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; - +using Duplicati.Library.Common; using FilterGroup = Duplicati.Library.Utility.FilterGroup; namespace Duplicati.CommandLine @@ -99,9 +99,9 @@ namespace Duplicati.CommandLine tp = tp.Replace("%MONO%", Library.Utility.Utility.IsMono ? "mono " : ""); tp = tp.Replace("%APP_PATH%", System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)); tp = tp.Replace("%PATH_SEPARATOR%", System.IO.Path.PathSeparator.ToString()); - tp = tp.Replace("%EXAMPLE_SOURCE_PATH%", Library.Utility.Utility.IsClientLinux ? "/source" : @"D:\source"); - tp = tp.Replace("%EXAMPLE_SOURCE_FILE%", Library.Utility.Utility.IsClientLinux ? "/source/myfile.txt" : @"D:\source\file.txt"); - tp = tp.Replace("%EXAMPLE_RESTORE_PATH%", Library.Utility.Utility.IsClientLinux ? "/restore" : @"D:\restore"); + tp = tp.Replace("%EXAMPLE_SOURCE_PATH%", Platform.IsClientLinux ? "/source" : @"D:\source"); + tp = tp.Replace("%EXAMPLE_SOURCE_FILE%", Platform.IsClientLinux ? "/source/myfile.txt" : @"D:\source\file.txt"); + tp = tp.Replace("%EXAMPLE_RESTORE_PATH%", Platform.IsClientLinux ? "/restore" : @"D:\restore"); tp = tp.Replace("%ENCRYPTIONMODULES%", string.Join(", ", Library.DynamicLoader.EncryptionLoader.Keys)); tp = tp.Replace("%COMPRESSIONMODULES%", string.Join(", ", Library.DynamicLoader.CompressionLoader.Keys)); tp = tp.Replace("%DEFAULTENCRYPTIONMODULE%", opts.EncryptionModule); @@ -111,7 +111,7 @@ namespace Duplicati.CommandLine tp = tp.Replace("%FILTER_GROUPS_SHORT%", string.Join(Environment.NewLine + " ", metaGroupNames.Concat(Enum.GetNames(typeof(FilterGroup)).Except(metaGroupNames, StringComparer.OrdinalIgnoreCase).OrderBy(x => x, StringComparer.OrdinalIgnoreCase)).Select(group => "{" + group + "}"))); tp = tp.Replace("%FILTER_GROUPS_LONG%", Library.Utility.FilterGroups.GetOptionDescriptions(4, true)); - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { // These properties are only valid for Windows tp = tp.Replace("%EXAMPLE_WILDCARD_DRIVE_SOURCE_PATH%", @"*:\source"); diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs index 338ad3f42..893cb8c03 100644 --- a/Duplicati/CommandLine/Program.cs +++ b/Duplicati/CommandLine/Program.cs @@ -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.Linq; using Duplicati.Library.Localization.Short; using Duplicati.Library.Utility; using System.IO; - +using Duplicati.Library.Common; + namespace Duplicati.CommandLine { public class Program @@ -51,7 +52,7 @@ namespace Duplicati.CommandLine { //If we are on Windows, append the bundled "win-tools" programs to the search path //We add it last, to allow the user to override with other versions - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { string wintools = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "win-tools"); Environment.SetEnvironmentVariable("PATH", diff --git a/Duplicati/CommandLine/RecoveryTool/Restore.cs b/Duplicati/CommandLine/RecoveryTool/Restore.cs index c9fd8586a..8a28dadc7 100644 --- a/Duplicati/CommandLine/RecoveryTool/Restore.cs +++ b/Duplicati/CommandLine/RecoveryTool/Restore.cs @@ -19,6 +19,7 @@ using System.IO; using System.Linq; using System.Collections.Generic; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.CommandLine.RecoveryTool { @@ -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) + if (Platform.IsClientLinux || largestprefix.Length > 0) largestprefix = Util.AppendDirSeparator(largestprefix); if (!string.IsNullOrEmpty(largestprefix)) diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs index 07c124b03..68cdd2705 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // // This library is free software; you can redistribute it and/or modify @@ -16,7 +16,8 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK using System; -using System.Collections.Generic; +using System.Collections.Generic; +using Duplicati.Library.Common; using Gdk; using Gtk; @@ -93,7 +94,7 @@ namespace Duplicati.GUI.TrayIcon else { m_item = new ImageMenuItem(text); - if (!Duplicati.Library.Utility.Utility.IsClientOSX) + if (!Platform.IsClientOSX) if (icon != MenuIcons.None) { ((ImageMenuItem)m_item).Image = GetIcon(icon); @@ -268,7 +269,7 @@ namespace Duplicati.GUI.TrayIcon { if (!_images.ContainsKey(icon)) { - if (Duplicati.Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) { switch (icon) { diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs index 7ab7687d4..9740cc752 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; +using Duplicati.Library.Common; using Duplicati.Library.Interface; namespace Duplicati.GUI.TrayIcon @@ -39,11 +40,11 @@ namespace Duplicati.GUI.TrayIcon private static string GetDefaultToolKit() { // No longer using Cocoa directly as it fails on 32bit as well - if (Duplicati.Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) return TOOLKIT_RUMPS; #if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK - if (Duplicati.Library.Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) { if (SupportsAppIndicator) return TOOLKIT_GTK_APP_INDICATOR; @@ -73,7 +74,7 @@ namespace Duplicati.GUI.TrayIcon List args = new List(_args); Dictionary options = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args); - if (Duplicati.Library.Utility.Utility.IsClientWindows && (Duplicati.Library.AutoUpdater.UpdaterManager.IsRunningInUpdateEnvironment || !Duplicati.Library.Utility.Utility.ParseBoolOption(options, DETACHED_PROCESS))) + if (Platform.IsClientWindows && (Duplicati.Library.AutoUpdater.UpdaterManager.IsRunningInUpdateEnvironment || !Duplicati.Library.Utility.Utility.ParseBoolOption(options, DETACHED_PROCESS))) Duplicati.Library.Utility.Win32.AttachConsole(Duplicati.Library.Utility.Win32.ATTACH_PARENT_PROCESS); foreach (string s in args) @@ -111,7 +112,7 @@ namespace Duplicati.GUI.TrayIcon if (!options.TryGetValue(TOOLKIT_OPTION, out toolkit)) { #if !(__MonoCS__ || __WindowsGTK__ || ENABLE_GTK) - if (Library.Utility.Utility.IsClientLinux && !Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientLinux && !Platform.IsClientOSX) Console.WriteLine("Warning: this build does not support GTK, rebuild with ENABLE_GTK defined"); #endif toolkit = GetDefaultToolKit(); @@ -444,7 +445,7 @@ namespace Duplicati.GUI.TrayIcon new Duplicati.Library.Interface.CommandLineArgument(BROWSER_COMMAND_OPTION, CommandLineArgument.ArgumentType.String, "Sets the browser command", "Set this option to override the default browser detection"), }; - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { args.Add(new Duplicati.Library.Interface.CommandLineArgument(DETACHED_PROCESS, CommandLineArgument.ArgumentType.String, "Runs the tray-icon detached", "This option runs the tray-icon in detached mode, meaning that the process will exit immediately and not send output to the console of the caller")); } diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs index 2e4ed8c85..1af64e34f 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs @@ -21,7 +21,8 @@ using System.Linq; using System.IO; using System.Threading.Tasks; using CoCoL; - +using Duplicati.Library.Common; + namespace Duplicati.GUI.TrayIcon { public class RumpsRunner : TrayIconBase @@ -130,7 +131,7 @@ namespace Duplicati.GUI.TrayIcon public static bool CanRun() { - if (!Library.Utility.Utility.IsClientOSX) + if (!Platform.IsClientOSX) return false; if (!File.Exists(SCRIPT_PATH) || !File.Exists(RUMPS_PYTHON)) diff --git a/Duplicati/Library/AutoUpdater/UpdaterManager.cs b/Duplicati/Library/AutoUpdater/UpdaterManager.cs index e17f1464b..b1e4b58af 100644 --- a/Duplicati/Library/AutoUpdater/UpdaterManager.cs +++ b/Duplicati/Library/AutoUpdater/UpdaterManager.cs @@ -22,6 +22,7 @@ using System.IO; using System.Threading.Tasks; using Duplicati.Library.Interface; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Library.AutoUpdater { @@ -124,14 +125,14 @@ namespace Duplicati.Library.AutoUpdater System.IO.Path.Combine(InstalledBaseDir, "updates"), }); - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { overrides.Add(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APPNAME, "updates")); overrides.Add(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), APPNAME, "updates")); } else { - if (Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) overrides.Add(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support", APPNAME, "updates")); overrides.Add(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), APPNAME, "updates")); @@ -143,7 +144,7 @@ namespace Duplicati.Library.AutoUpdater if (!string.IsNullOrWhiteSpace(programfiles)) legacypaths.Add(System.IO.Path.Combine(programfiles, APPNAME, "updates")); - if (Library.Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) legacypaths.Add(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APPNAME, "updates")); // The real attempts that we probe for @@ -153,7 +154,7 @@ namespace Duplicati.Library.AutoUpdater if (!string.IsNullOrWhiteSpace(programfiles) && !InstalledBaseDir.StartsWith(Util.AppendDirSeparator(programfiles), StringComparison.Ordinal)) attempts.Add(System.IO.Path.Combine(InstalledBaseDir, "updates")); - if (Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) attempts.Add(System.IO.Path.Combine("/", "Library", "Application Support", APPNAME, "updates")); else attempts.Add(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), APPNAME, "updates")); @@ -1083,7 +1084,7 @@ namespace Duplicati.Library.AutoUpdater if (IsRunningInUpdateEnvironment) { // For some reason this does not work - //if (Library.Utility.Utility.IsClientWindows) + //if (Platform.IsClientWindows) //Duplicati.Library.Utility.Win32.AttachConsole(Duplicati.Library.Utility.Win32.ATTACH_PARENT_PROCESS); int r = 0; @@ -1124,7 +1125,7 @@ namespace Duplicati.Library.AutoUpdater pi.EnvironmentVariables["LOCALIZATION_FOLDER"] = InstalledBaseDir; // On Windows, we manually redirect the streams - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { pi.RedirectStandardError = true; pi.RedirectStandardInput = true; @@ -1133,7 +1134,7 @@ namespace Duplicati.Library.AutoUpdater var proc = System.Diagnostics.Process.Start(pi); Task tasks = null; - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { // On Windows, we manually redirect the streams tasks = Task.WhenAll( diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index b61b68fb4..2fcfcd67c 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using Duplicati.Library.Interface; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Library.Backend { @@ -73,7 +74,7 @@ namespace Duplicati.Library.Backend paths.AddRange(options[OPTION_ALTERNATE_PATHS].Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)); //On windows we expand the drive letter * to all drives - if (!Utility.Utility.IsClientLinux) + if (!Platform.IsClientLinux) { System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); @@ -290,7 +291,7 @@ namespace Duplicati.Library.Backend private System.IO.DriveInfo GetDrive() { string root; - if (Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) { string path = Util.AppendDirSeparator(systemIO.PathGetFullPath(m_path)); root = "/"; @@ -309,7 +310,7 @@ namespace Duplicati.Library.Backend // On Windows, DriveInfo is only valid for lettered drives. (e.g., not for UNC paths and shares) // So only attempt to get it if we aren't on Windows or if the root starts with a letter. - if (!Utility.Utility.IsClientWindows || (root.Length > 0 && char.IsLetter(root[0]))) + if (!Platform.IsClientWindows || (root.Length > 0 && char.IsLetter(root[0]))) { try { @@ -334,7 +335,7 @@ namespace Duplicati.Library.Backend return new QuotaInfo(driveInfo.TotalSize, driveInfo.AvailableFreeSpace); } - if (Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { // If we can't get the DriveInfo on Windows, fallback to GetFreeDiskSpaceEx // https://stackoverflow.com/questions/2050343/programmatically-determining-space-available-from-unc-path diff --git a/Duplicati/Library/IO/Platform/Platform.cs b/Duplicati/Library/IO/Platform/Platform.cs index 47974a1f5..1cfb1b987 100644 --- a/Duplicati/Library/IO/Platform/Platform.cs +++ b/Duplicati/Library/IO/Platform/Platform.cs @@ -28,5 +28,81 @@ namespace Duplicati.Library.Common /// Gets a value indicating if the client is Windows based /// public static bool IsClientWindows => !IsClientLinux; + + + private static string UNAME; + + /// + /// Gets or sets a value indicating if the client is running OSX + /// + public static bool IsClientOSX + { + get + { + // Sadly, Mono returns Unix when running on OSX + //return Environment.OSVersion.Platform == PlatformID.MacOSX; + + if (!IsClientLinux) + return false; + + try + { + if (UNAME == null) + { + var psi = new System.Diagnostics.ProcessStartInfo("uname") + { + RedirectStandardOutput = true, + RedirectStandardInput = false, + RedirectStandardError = false, + UseShellExecute = false + }; + + var pi = System.Diagnostics.Process.Start(psi); + pi.WaitForExit(5000); + if (pi.HasExited) + UNAME = pi.StandardOutput.ReadToEnd().Trim(); + } + } + catch + { + } + + return "Darwin".Equals(UNAME); + + } + } + /// + /// Gets the output of "uname -a" on Linux, or null on Windows + /// + public static string UnameAll + { + get + { + if (!IsClientLinux) + return null; + + try + { + var psi = new System.Diagnostics.ProcessStartInfo("uname", "-a") + { + RedirectStandardOutput = true, + RedirectStandardError = false, + RedirectStandardInput = false, + UseShellExecute = false + }; + + var pi = System.Diagnostics.Process.Start(psi); + pi.WaitForExit(5000); + if (pi.HasExited) + return pi.StandardOutput.ReadToEnd().Trim(); + } + catch + { + // ignored + } + + return null; + } + } } } diff --git a/Duplicati/Library/Main/Controller.cs b/Duplicati/Library/Main/Controller.cs index b4fa50e91..dd4429a0f 100644 --- a/Duplicati/Library/Main/Controller.cs +++ b/Duplicati/Library/Main/Controller.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using Duplicati.Library.Utility; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Library.Main { @@ -826,7 +827,7 @@ namespace Duplicati.Library.Main { List expandedSources = new List(); - if (Library.Utility.Utility.IsClientWindows && (inputsource.StartsWith("*:", StringComparison.Ordinal) || inputsource.StartsWith("?:", StringComparison.Ordinal))) + if (Platform.IsClientWindows && (inputsource.StartsWith("*:", StringComparison.Ordinal) || inputsource.StartsWith("?:", StringComparison.Ordinal))) { // *: drive paths are only supported on Windows clients // Lazily load the drive info @@ -841,7 +842,7 @@ namespace Duplicati.Library.Main expandedSources.Add(expandedSource); } } - else if (Library.Utility.Utility.IsClientWindows && inputsource.StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase)) + else if (Platform.IsClientWindows && inputsource.StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase)) { // In order to specify a drive by it's volume name, adopt the volume guid path syntax: // \\?\Volume{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} diff --git a/Duplicati/Library/Main/Database/LocalBugReportDatabase.cs b/Duplicati/Library/Main/Database/LocalBugReportDatabase.cs index 15be9fb4e..de426ea5c 100644 --- a/Duplicati/Library/Main/Database/LocalBugReportDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalBugReportDatabase.cs @@ -16,6 +16,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 System; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; namespace Duplicati.Library.Main.Database @@ -47,7 +48,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:\\", Util.DirectorySeparatorString, Util.DirectorySeparatorString, Util.DirectorySeparatorString, ".bin"); + upcmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Obfuscated"" = ? || length(""RealPath"") || ? || ""ID"" || (CASE WHEN substr(""RealPath"", length(""RealPath"")) = ? THEN ? ELSE ? END) ", tablename), Platform.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))) diff --git a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs index e36b6f543..1d2a53d91 100644 --- a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; using Duplicati.Library.Main.Volumes; @@ -389,14 +390,14 @@ namespace Duplicati.Library.Main.Database // defaults when restoring cross OS, e.g. backup on Linux, restore on Windows //This is mostly meaningless, and the user really should use --restore-path - if (Library.Utility.Utility.IsClientLinux && dirsep == "\\") + if (Platform.IsClientLinux && dirsep == "\\") { // For Win -> Linux, we remove the colon from the drive letter, and use the drive letter as root folder cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Targetpath"" = CASE WHEN SUBSTR(""Path"", 2, 1) == "":"" THEN ""\\"" || SUBSTR(""Path"", 1, 1) || SUBSTR(""Path"", 3) ELSE ""Path"" END", m_tempfiletable)); cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Targetpath"" = CASE WHEN SUBSTR(""Path"", 1, 2) == ""\\"" THEN ""\\"" || SUBSTR(""Path"", 2) ELSE ""Path"" END", m_tempfiletable)); } - else if (Library.Utility.Utility.IsClientWindows && dirsep == "/") + else if (Platform.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), Util.AppendDirSeparator(System.IO.Path.GetPathRoot(Library.Utility.TempFolder.SystemTempPath)).Replace("\\", "/")); @@ -427,10 +428,10 @@ namespace Duplicati.Library.Main.Database } // Cross-os path remapping support - if (Library.Utility.Utility.IsClientLinux && dirsep == "\\") + if (Platform.IsClientLinux && dirsep == "\\") // For Win paths on Linux cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = REPLACE(""TargetPath"", ""\"", ""/"")", m_tempfiletable)); - else if (Library.Utility.Utility.IsClientWindows && dirsep == "/") + else if (Platform.IsClientWindows && dirsep == "/") // For Linux paths on Windows cmd.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""TargetPath"" = REPLACE(REPLACE(""TargetPath"", ""\"", ""_""), ""/"", ""\"")", m_tempfiletable)); diff --git a/Duplicati/Library/Main/DatabaseLocator.cs b/Duplicati/Library/Main/DatabaseLocator.cs index bf726acc5..bb267a04f 100644 --- a/Duplicati/Library/Main/DatabaseLocator.cs +++ b/Duplicati/Library/Main/DatabaseLocator.cs @@ -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 Newtonsoft.Json.Serialization; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Main { public static class DatabaseLocator @@ -58,7 +59,7 @@ namespace Duplicati.Library.Main var folder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duplicati"); - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { var newlocation = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Duplicati"); diff --git a/Duplicati/Library/Main/Operation/BackupHandler.cs b/Duplicati/Library/Main/Operation/BackupHandler.cs index d83086703..e492bb426 100644 --- a/Duplicati/Library/Main/Operation/BackupHandler.cs +++ b/Duplicati/Library/Main/Operation/BackupHandler.cs @@ -33,6 +33,7 @@ using System.Threading; using Duplicati.Library.Snapshots; using Duplicati.Library.Utility; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Library.Main.Operation { @@ -84,7 +85,7 @@ namespace Duplicati.Library.Main.Operation Logging.Log.WriteWarningMessage(LOGTAG, "SnapshotFailed", ex, Strings.Common.SnapshotFailedError(ex.ToString())); } - return Library.Utility.Utility.IsClientLinux ? + return Platform.IsClientLinux ? (Library.Snapshots.ISnapshotService)new Duplicati.Library.Snapshots.NoSnapshotLinux() : (Library.Snapshots.ISnapshotService)new Duplicati.Library.Snapshots.NoSnapshotWindows(); diff --git a/Duplicati/Library/Main/Operation/SystemInfoHandler.cs b/Duplicati/Library/Main/Operation/SystemInfoHandler.cs index cacd72919..1bbd08eb5 100644 --- a/Duplicati/Library/Main/Operation/SystemInfoHandler.cs +++ b/Duplicati/Library/Main/Operation/SystemInfoHandler.cs @@ -18,7 +18,8 @@ using System; using System.Collections.Generic; using Duplicati.Library.Interface; using System.Linq; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Main.Operation { internal static class SystemInfoHandler @@ -39,7 +40,7 @@ namespace Duplicati.Library.Main.Operation yield return string.Format("Current Version folder {0}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); yield return string.Format("OS: {0}", Environment.OSVersion); - yield return string.Format("Uname: {0}", Duplicati.Library.Utility.Utility.UnameAll); + yield return string.Format("Uname: {0}", Platform.UnameAll); yield return string.Format("64bit: {0} ({1})", Environment.Is64BitOperatingSystem, Environment.Is64BitProcess); yield return string.Format("Machinename: {0}", Environment.MachineName); diff --git a/Duplicati/Library/Main/ProcessController.cs b/Duplicati/Library/Main/ProcessController.cs index 0e66428b4..acbba2fc6 100755 --- a/Duplicati/Library/Main/ProcessController.cs +++ b/Duplicati/Library/Main/ProcessController.cs @@ -16,6 +16,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Linq; +using Duplicati.Library.Common; using Duplicati.Library.Utility; namespace Duplicati.Library.Main @@ -98,7 +99,7 @@ namespace Duplicati.Library.Main /// private void StartSleepPrevention() { - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { try { @@ -110,7 +111,7 @@ namespace Duplicati.Library.Main Logging.Log.WriteWarningMessage(LOGTAG, "SleepPrevetionError", ex, "Failed to set sleep prevention"); } } - else if (Duplicati.Library.Utility.Utility.IsClientOSX) + else if (Platform.IsClientOSX) { try { @@ -144,7 +145,7 @@ namespace Duplicati.Library.Main { var pid = System.Diagnostics.Process.GetCurrentProcess().Id; - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { var handle = System.Diagnostics.Process.GetCurrentProcess().Handle; @@ -181,7 +182,7 @@ namespace Duplicati.Library.Main } else { - if (Duplicati.Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) { var data = RunProcessAndGetResult("ps", $"-onice -p {pid}"); if (data.Item1 != 0) @@ -251,7 +252,7 @@ namespace Duplicati.Library.Main /// private void StopSleepPrevention() { - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { try { @@ -266,7 +267,7 @@ namespace Duplicati.Library.Main Logging.Log.WriteWarningMessage(LOGTAG, "SleepPrevetionError", ex, "Failed to set sleep prevention"); } } - else if (Duplicati.Library.Utility.Utility.IsClientOSX) + else if (Platform.IsClientOSX) { try { @@ -299,7 +300,7 @@ namespace Duplicati.Library.Main /// private void DeactivateBackgroundIOPriority() { - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { try { @@ -342,7 +343,7 @@ namespace Duplicati.Library.Main var pid = System.Diagnostics.Process.GetCurrentProcess().Id; Tuple data; - if (Duplicati.Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) { // TODO: We can only give lower priority, thus not reset it ... data = RunProcessAndGetResult($"renice", $"{m_originalNiceLevel} -p {pid}"); diff --git a/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs b/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs index 8537a078d..f1cd0db63 100644 --- a/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs +++ b/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -20,7 +20,8 @@ using System; using System.Collections.Generic; using System.Text; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Modules.Builtin { public class ConsolePasswordInput : Duplicati.Library.Interface.IGenericModule @@ -62,7 +63,7 @@ namespace Duplicati.Library.Modules.Builtin catch (InvalidOperationException) { // Handle redirect issues on Windows only - if (!Library.Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) throw; commandlineOptions["passphrase"] = ReadPassphraseFromStdin(confirm); diff --git a/Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj b/Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj index 8cc2019b5..761ef16bb 100644 --- a/Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj +++ b/Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj @@ -108,6 +108,10 @@ {D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB} Duplicati.Library.OAuthHelper + + {D63E53E4-A458-4C2F-914D-92F715F58ACF} + Duplicati.Library.Common + diff --git a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs index 9d40d860a..e56130d4f 100644 --- a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs +++ b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using Duplicati.Library.Common; using Duplicati.Library.Snapshots; namespace Duplicati.Library.Modules.Builtin @@ -53,7 +54,7 @@ namespace Duplicati.Library.Modules.Builtin public bool LoadAsDefault { - get { return Utility.Utility.IsClientWindows; } + get { return Platform.IsClientWindows; } } public IList SupportedCommands @@ -72,7 +73,7 @@ namespace Duplicati.Library.Modules.Builtin public Dictionary ParseSourcePaths(ref string[] paths, ref string filter, Dictionary commandlineOptions) { // Early exit in case we are non-windows to prevent attempting to load Windows-only components - if (!Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) { Logging.Log.WriteWarningMessage(LOGTAG, "HyperVWindowsOnly", null, "Hyper-V backup works only on Windows OS"); @@ -216,7 +217,7 @@ namespace Duplicati.Library.Modules.Builtin public bool ContainFilesForBackup(string[] paths) { - if (paths == null || !Utility.Utility.IsClientWindows) + if (paths == null || !Platform.IsClientWindows) return false; return paths.Where(x => !string.IsNullOrWhiteSpace(x)).Any(x => x.Equals(m_HyperVPathAllRegExp, StringComparison.OrdinalIgnoreCase) || Regex.IsMatch(x, m_HyperVPathGuidRegExp, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)); diff --git a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs index 8c60df25a..6bdb1a072 100644 --- a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs +++ b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using Duplicati.Library.Common; using Duplicati.Library.Snapshots; namespace Duplicati.Library.Modules.Builtin @@ -54,7 +55,7 @@ namespace Duplicati.Library.Modules.Builtin public bool LoadAsDefault { - get { return Utility.Utility.IsClientWindows; } + get { return Platform.IsClientWindows; } } public IList SupportedCommands @@ -73,7 +74,7 @@ namespace Duplicati.Library.Modules.Builtin public Dictionary ParseSourcePaths(ref string[] paths, ref string filter, Dictionary commandlineOptions) { // Early exit in case we are non-windows to prevent attempting to load Windows-only components - if (!Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) { Logging.Log.WriteWarningMessage(LOGTAG, "MSSqlWindowsOnly", null, "Microsoft SQL Server databases backup works only on Windows OS"); @@ -214,7 +215,7 @@ namespace Duplicati.Library.Modules.Builtin public bool ContainFilesForBackup(string[] paths) { - if (paths == null || !Utility.Utility.IsClientWindows) + if (paths == null || !Platform.IsClientWindows) return false; return paths.Where(x => !string.IsNullOrWhiteSpace(x)).Any(x => x.Equals(m_MSSQLPathAllRegExp, StringComparison.OrdinalIgnoreCase) || Regex.IsMatch(x, m_MSSQLPathDBRegExp, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)); diff --git a/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj b/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj index 61301cc9e..95f77f55f 100644 --- a/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj +++ b/Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj @@ -88,5 +88,9 @@ {D10A5FC0-11B4-4E70-86AA-8AEA52BD9798} Duplicati.Library.Logging + + {D63E53E4-A458-4C2F-914D-92F715F58ACF} + Duplicati.Library.Common + diff --git a/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs index e62c40ab1..68697039c 100644 --- a/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs +++ b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -19,7 +19,8 @@ #endregion using System; using System.IO; - +using Duplicati.Library.Common; + namespace Duplicati.Library.SQLiteHelper { public static class SQLiteLoader @@ -264,14 +265,14 @@ namespace Duplicati.Library.SQLiteHelper // Check if SQLite database exists before opening a connection to it. // This information is used to 'fix' permissions on a newly created file. var fileExists = false; - if (!Library.Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) fileExists = File.Exists(path); con.ConnectionString = "Data Source=" + path; con.Open(); // If we are non-Windows, make the file only accessible by the current user - if (!Library.Utility.Utility.IsClientWindows && !fileExists) + if (!Platform.IsClientWindows && !fileExists) SetUnixPermissionUserRWOnly(path); } diff --git a/Duplicati/Library/Snapshots/HyperVUtility.cs b/Duplicati/Library/Snapshots/HyperVUtility.cs index f4ce0f060..a80f32831 100644 --- a/Duplicati/Library/Snapshots/HyperVUtility.cs +++ b/Duplicati/Library/Snapshots/HyperVUtility.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Management; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; namespace Duplicati.Library.Snapshots @@ -93,7 +94,7 @@ namespace Duplicati.Library.Snapshots { Guests = new List(); - if (!Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) { IsHyperVInstalled = false; IsVSSWriterSupported = false; diff --git a/Duplicati/Library/Snapshots/MSSQLUtility.cs b/Duplicati/Library/Snapshots/MSSQLUtility.cs index adcc2bdf5..add7622fc 100644 --- a/Duplicati/Library/Snapshots/MSSQLUtility.cs +++ b/Duplicati/Library/Snapshots/MSSQLUtility.cs @@ -1,4 +1,5 @@ -using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; +using Duplicati.Library.Common.IO; using System; using System.Collections.Generic; using System.Linq; @@ -84,7 +85,7 @@ namespace Duplicati.Library.Snapshots { m_DBs = new List(); - if (!Utility.Utility.IsClientWindows) + if (!Platform.IsClientWindows) { IsMSSQLInstalled = false; return; diff --git a/Duplicati/Library/Snapshots/Program.cs b/Duplicati/Library/Snapshots/Program.cs index e139d2ff8..f9d6044c9 100644 --- a/Duplicati/Library/Snapshots/Program.cs +++ b/Duplicati/Library/Snapshots/Program.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -20,7 +20,8 @@ using System; using System.Collections.Generic; using System.Text; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Snapshots { static class Program @@ -104,7 +105,7 @@ Where is the folder where files will be locked/created etc"); } Console.WriteLine("Creating snapshot for folder: {0}", args[0]); - Console.WriteLine("If this fails, try to run as " + (Utility.Utility.IsClientLinux ? "root" : "Administrator")); + Console.WriteLine("If this fails, try to run as " + (Platform.IsClientLinux ? "root" : "Administrator")); using (ISnapshotService snapshot = SnapshotUtility.CreateSnapshot(new[] { args[0] }, options)) { Console.WriteLine("Attempting to read locked file via snapshot"); diff --git a/Duplicati/Library/Snapshots/SnapshotUtility.cs b/Duplicati/Library/Snapshots/SnapshotUtility.cs index bddfd8201..083859fe0 100644 --- a/Duplicati/Library/Snapshots/SnapshotUtility.cs +++ b/Duplicati/Library/Snapshots/SnapshotUtility.cs @@ -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.Collections.Generic; using System.IO; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; namespace Duplicati.Library.Snapshots @@ -38,7 +39,7 @@ namespace Duplicati.Library.Snapshots public static ISnapshotService CreateSnapshot(IEnumerable folders, Dictionary options) { return - Utility.Utility.IsClientLinux + Platform.IsClientLinux ? CreateLinuxSnapshot(folders) : CreateWindowsSnapshot(folders, options); diff --git a/Duplicati/Library/Snapshots/USNJournal.cs b/Duplicati/Library/Snapshots/USNJournal.cs index 138e20d58..d0841db0f 100644 --- a/Duplicati/Library/Snapshots/USNJournal.cs +++ b/Duplicati/Library/Snapshots/USNJournal.cs @@ -26,6 +26,7 @@ using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Runtime.Serialization; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; using Microsoft.Win32.SafeHandles; @@ -91,7 +92,7 @@ namespace Duplicati.Library.Snapshots /// The root volume where the USN lookup is performed internal USNJournal(string volumeRoot) { - if (Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) throw new Interface.UserInformationException(Strings.USNHelper.LinuxNotSupportedError, "UsnOnLinuxNotSupported"); m_volume = Util.AppendDirSeparator(volumeRoot); diff --git a/Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj b/Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj index b00614bad..fca2f916f 100644 --- a/Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj +++ b/Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj @@ -62,6 +62,10 @@ {D10A5FC0-11B4-4E70-86AA-8AEA52BD9798} Duplicati.Library.Logging + + {D63E53E4-A458-4C2F-914D-92F715F58ACF} + Duplicati.Library.Common + diff --git a/Duplicati/Library/UsageReporter/OSInfoHelper.cs b/Duplicati/Library/UsageReporter/OSInfoHelper.cs index a3012033f..44b0165eb 100644 --- a/Duplicati/Library/UsageReporter/OSInfoHelper.cs +++ b/Duplicati/Library/UsageReporter/OSInfoHelper.cs @@ -17,7 +17,8 @@ using System; using System.Collections.Generic; using System.Linq; - +using Duplicati.Library.Common; + namespace Duplicati.Library.UsageReporter { /// @@ -71,11 +72,11 @@ namespace Duplicati.Library.UsageReporter { get { - if (!Utility.Utility.IsClientLinux) + if (!Platform.IsClientLinux) { return Environment.OSVersion.ToString(); } - else if (Utility.Utility.IsClientOSX) + else if (Platform.IsClientOSX) { var m = RunProgramAndReadOutput("sw_vers", null); if (m != null) diff --git a/Duplicati/Library/UsageReporter/ReportSet.cs b/Duplicati/Library/UsageReporter/ReportSet.cs index 4b10c5df5..b99c4ce75 100644 --- a/Duplicati/Library/UsageReporter/ReportSet.cs +++ b/Duplicati/Library/UsageReporter/ReportSet.cs @@ -18,7 +18,8 @@ using System; using Newtonsoft.Json; using System.Linq; using System.Collections.Generic; - +using Duplicati.Library.Common; + namespace Duplicati.Library.UsageReporter { /// @@ -44,9 +45,9 @@ namespace Duplicati.Library.UsageReporter [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static void DoInitOS() { - if (Library.Utility.Utility.IsClientOSX) + if (Platform.IsClientOSX) Cached_OSType = "OSX"; - else if (Library.Utility.Utility.IsClientLinux) + else if (Platform.IsClientLinux) Cached_OSType = "Linux"; else if (new PlatformID[] { PlatformID.Win32NT, diff --git a/Duplicati/Library/Utility/FilterGroups.cs b/Duplicati/Library/Utility/FilterGroups.cs index 1e5582876..5e115fbe4 100644 --- a/Duplicati/Library/Utility/FilterGroups.cs +++ b/Duplicati/Library/Utility/FilterGroups.cs @@ -17,7 +17,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Duplicati.Library.Common.IO; + +using Duplicati.Library.Common; + using Duplicati.Library.Localization.Short; namespace Duplicati.Library.Utility @@ -111,12 +113,12 @@ namespace Duplicati.Library.Utility /// /// Regex escaped string for the AltDirectorySeparatorChar /// - private static readonly string RegexEscapedAltDirectorySeparatorChar = System.Text.RegularExpressions.Regex.Escape(Util.AltDirectorySeparatorString); + private static readonly string RegexEscapedAltDirectorySeparatorChar = System.Text.RegularExpressions.Regex.Escape(Common.IO.Util.AltDirectorySeparatorString); /// /// Regex escaped string for the DirectorySeparatorChar /// - private static readonly string RegexEscapedDirectorySeparatorChar = System.Text.RegularExpressions.Regex.Escape(Util.DirectorySeparatorString); + private static readonly string RegexEscapedDirectorySeparatorChar = System.Text.RegularExpressions.Regex.Escape(Common.IO.Util.DirectorySeparatorString); /// /// Gets the list of alternate aliases which can refer to this group. @@ -229,11 +231,11 @@ namespace Duplicati.Library.Utility { IEnumerable osFilters; - if (Utility.IsClientOSX) + if (Platform.IsClientOSX) osFilters = CreateOSXFilters(group); - else if (Utility.IsClientLinux) + else if (Platform.IsClientLinux) osFilters = CreateLinuxFilters(group); - else if (Utility.IsClientWindows) + else if (Platform.IsClientWindows) osFilters = CreateWindowsFilters(group); else throw new ArgumentException("Unknown operating system?"); @@ -269,7 +271,7 @@ namespace Duplicati.Library.Utility if (n.Length > 2 && char.IsLetter(n[0]) && n[1] == ':' && wildcardRootWindowsPaths.Contains(n.Substring(2))) continue; - else if (prev != null && prev.EndsWith(Util.DirectorySeparatorString, StringComparison.Ordinal) && n.StartsWith(prev, Utility.ClientFilenameStringComparison)) + else if (prev != null && prev.EndsWith(Common.IO.Util.DirectorySeparatorString, StringComparison.Ordinal) && n.StartsWith(prev, Utility.ClientFilenameStringComparison)) continue; else yield return prev = n; @@ -357,7 +359,7 @@ namespace Duplicati.Library.Utility yield return windir; // Also exclude "C:\Windows.old\" - yield return Util.AppendDirSeparator(windir.TrimEnd('\\', '/') + ".old"); + yield return Common.IO.Util.AppendDirSeparator(windir.TrimEnd('\\', '/') + ".old"); } } @@ -582,7 +584,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 Util.AppendDirSeparator(filter); + return Common.IO.Util.AppendDirSeparator(filter); } else { @@ -621,7 +623,7 @@ namespace Duplicati.Library.Utility private static IEnumerable GetOSXExcludeFiles() { var res = new List(); - if (Utility.IsClientOSX) + if (Platform.IsClientOSX) { try { @@ -679,7 +681,7 @@ namespace Duplicati.Library.Utility /// The list of paths to exclude. private static string[] GetWindowsRegistryFilters() { - if (Utility.IsClientWindows) + if (Platform.IsClientWindows) { // One Windows, filters may also be stored in the registry try diff --git a/Duplicati/Library/Utility/Power/PowerSupply.cs b/Duplicati/Library/Utility/Power/PowerSupply.cs index 09b653fca..d9e89dc8f 100644 --- a/Duplicati/Library/Utility/Power/PowerSupply.cs +++ b/Duplicati/Library/Utility/Power/PowerSupply.cs @@ -15,6 +15,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 Duplicati.Library.Common; + namespace Duplicati.Library.Utility.Power { public static class PowerSupply @@ -31,15 +33,15 @@ namespace Duplicati.Library.Utility.Power IPowerSupplyState state; // Since IsClientLinux returns true when on Mac OS X, we need to check IsClientOSX first. - if (Utility.IsClientOSX) + if (Platform.IsClientOSX) { state = new MacOSPowerSupplyState(); } - else if (Utility.IsClientLinux) + else if (Platform.IsClientLinux) { state = new LinuxPowerSupplyState(); } - else if (Utility.IsClientWindows) + else if (Platform.IsClientWindows) { state = new WindowsPowerSupplyState(); } diff --git a/Duplicati/Library/Utility/SslCertificateValidator.cs b/Duplicati/Library/Utility/SslCertificateValidator.cs index f5319ff57..ed4cbd3e3 100644 --- a/Duplicati/Library/Utility/SslCertificateValidator.cs +++ b/Duplicati/Library/Utility/SslCertificateValidator.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -18,11 +18,10 @@ // #endregion using System; -using System.Collections.Generic; -using System.Text; using System.Security.Cryptography.X509Certificates; using System.Net.Security; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Utility { public class SslCertificateValidator @@ -37,7 +36,7 @@ namespace Duplicati.Library.Utility public SslPolicyErrors SslError { get { return m_errors; } } public InvalidCertificateException(string certificate, SslPolicyErrors error) - : base(Strings.SslCertificateValidator.VerifyCertificateException(error, certificate) + (Utility.IsClientLinux ? Strings.SslCertificateValidator.MonoHelpSSL : "")) + : base(Strings.SslCertificateValidator.VerifyCertificateException(error, certificate) + (Platform.IsClientLinux ? Strings.SslCertificateValidator.MonoHelpSSL : "")) { m_certificate = certificate; m_errors = error; diff --git a/Duplicati/Library/Utility/UrlUtility.cs b/Duplicati/Library/Utility/UrlUtility.cs index 8e2c87a36..eddebe7a8 100644 --- a/Duplicati/Library/Utility/UrlUtility.cs +++ b/Duplicati/Library/Utility/UrlUtility.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -20,7 +20,8 @@ using System; using System.Collections.Generic; using System.Text; - +using Duplicati.Library.Common; + namespace Duplicati.Library.Utility { public static class UrlUtility @@ -54,7 +55,7 @@ namespace Duplicati.Library.Utility browserprogram = SystemBrowser; //Fallback is to just show the window in a browser - if (Utility.IsClientOSX) + if (Platform.IsClientOSX) { try { @@ -67,7 +68,7 @@ namespace Duplicati.Library.Utility ErrorHandler(string.Format("Unable to open a browser window, please manually visit: \r\n{0}", url)); } } - else if (Utility.IsClientLinux) + else if (Platform.IsClientLinux) { try { diff --git a/Duplicati/Library/Utility/Utility.cs b/Duplicati/Library/Utility/Utility.cs index 65ada56b8..c08bdb7aa 100644 --- a/Duplicati/Library/Utility/Utility.cs +++ b/Duplicati/Library/Utility/Utility.cs @@ -22,6 +22,7 @@ using System.Threading.Tasks; using System.Text; using System.Text.RegularExpressions; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Library.Utility { @@ -436,13 +437,13 @@ namespace Duplicati.Library.Utility if (last == -1 || last == 0 && len == 0) return null; - if (last == 0 && !IsClientWindows) + if (last == 0 && !Platform.IsClientWindows) return Util.DirectorySeparatorString; var parent = path.Substring(0, last); if (forceTrailingDirectorySeparator || - IsClientWindows && parent.Length == 2 && parent[1] == ':' && char.IsLetter(parent[0])) + Platform.IsClientWindows && parent.Length == 2 && parent[1] == ':' && char.IsLetter(parent[0])) { parent += Path.DirectorySeparatorChar; } @@ -824,7 +825,7 @@ namespace Duplicati.Library.Utility public static bool Which(string appname) { - if (!IsClientLinux) + if (!Platform.IsClientLinux) return false; try @@ -851,89 +852,6 @@ namespace Duplicati.Library.Utility return false; } - private static string UNAME; - - /// - /// Gets or sets a value indicating if the client is running OSX - /// - public static bool IsClientOSX - { - get - { - // Sadly, Mono returns Unix when running on OSX - //return Environment.OSVersion.Platform == PlatformID.MacOSX; - - if (!IsClientLinux) - return false; - - try - { - if (UNAME == null) - { - var psi = new System.Diagnostics.ProcessStartInfo("uname") - { - RedirectStandardOutput = true, - RedirectStandardInput = false, - RedirectStandardError = false, - UseShellExecute = false - }; - - var pi = System.Diagnostics.Process.Start(psi); - pi.WaitForExit(5000); - if (pi.HasExited) - UNAME = pi.StandardOutput.ReadToEnd().Trim(); - } - } - catch - { - } - - return "Darwin".Equals(UNAME); - - } - } - /// - /// Gets the output of "uname -a" on Linux, or null on Windows - /// - public static string UnameAll - { - get - { - if (!IsClientLinux) - return null; - - try - { - var psi = new System.Diagnostics.ProcessStartInfo("uname", "-a") - { - RedirectStandardOutput = true, - RedirectStandardError = false, - RedirectStandardInput = false, - UseShellExecute = false - }; - - var pi = System.Diagnostics.Process.Start(psi); - pi.WaitForExit(5000); - if (pi.HasExited) - return pi.StandardOutput.ReadToEnd().Trim(); - } - catch - { - // ignored - } - - return null; - } - } - /// - /// Gets or sets a value indicating if the client is Linux/Unix based - /// - public static bool IsClientLinux => Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX; - - /// - /// Gets a value indicating if the client is Windows based - /// - public static bool IsClientWindows => !IsClientLinux; /// /// Returns a value indicating if the filesystem, is case sensitive @@ -948,7 +866,7 @@ namespace Duplicati.Library.Utility // TODO: This should probably be determined by filesystem rather than OS, // OSX can actually have the disks formated as Case Sensitive, but insensitive is default - CachedIsFSCaseSensitive = ParseBool(str, () => IsClientLinux && !IsClientOSX); + CachedIsFSCaseSensitive = ParseBool(str, () => Platform.IsClientLinux && !Platform.IsClientOSX); } return CachedIsFSCaseSensitive.Value; @@ -1026,7 +944,7 @@ namespace Duplicati.Library.Utility /// /// The path to the users home directory /// - public static readonly string HOME_PATH = Environment.GetFolderPath(IsClientLinux ? Environment.SpecialFolder.Personal : Environment.SpecialFolder.UserProfile); + public static readonly string HOME_PATH = Environment.GetFolderPath(Platform.IsClientLinux ? Environment.SpecialFolder.Personal : Environment.SpecialFolder.UserProfile); /// /// Regexp for matching environment variables on Windows (%VAR%) @@ -1495,7 +1413,7 @@ namespace Duplicati.Library.Utility if (string.IsNullOrWhiteSpace(arg)) return arg; - if (!IsClientWindows) + if (!Platform.IsClientWindows) { // We could consider using single quotes that prevents all expansions //if (!allowEnvExpansion) diff --git a/Duplicati/Server/Database/ServerSettings.cs b/Duplicati/Server/Database/ServerSettings.cs index 931360587..c808eac18 100644 --- a/Duplicati/Server/Database/ServerSettings.cs +++ b/Duplicati/Server/Database/ServerSettings.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -23,7 +23,8 @@ using System.Security.Cryptography.X509Certificates; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Pkcs; using Org.BouncyCastle.Security; - +using Duplicati.Library.Common; + namespace Duplicati.Server.Database { public class ServerSettings @@ -495,7 +496,7 @@ namespace Duplicati.Server.Database if (String.IsNullOrEmpty(m_values[CONST.SERVER_SSL_CERTIFICATE])) return null; - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) return new X509Certificate2(Convert.FromBase64String(m_values[CONST.SERVER_SSL_CERTIFICATE])); else { @@ -527,7 +528,7 @@ namespace Duplicati.Server.Database } else { - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) lock (m_connection.m_lock) m_values[CONST.SERVER_SSL_CERTIFICATE] = Convert.ToBase64String(value.Export(X509ContentType.Pkcs12)); else diff --git a/Duplicati/Server/LiveControls.cs b/Duplicati/Server/LiveControls.cs index 3ebafd249..a02baf0b3 100644 --- a/Duplicati/Server/LiveControls.cs +++ b/Duplicati/Server/LiveControls.cs @@ -1,4 +1,4 @@ -#region Disclaimer / License +#region Disclaimer / License // Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // @@ -20,7 +20,8 @@ using System; using System.Collections.Generic; using System.Text; - +using Duplicati.Library.Common; + namespace Duplicati.Server { /// @@ -210,7 +211,7 @@ namespace Duplicati.Server try { - if (!Library.Utility.Utility.IsClientLinux) + if (!Platform.IsClientLinux) RegisterHibernateMonitor(); } catch { } diff --git a/Duplicati/Server/Program.cs b/Duplicati/Server/Program.cs index 1fe3844a4..e74294866 100644 --- a/Duplicati/Server/Program.cs +++ b/Duplicati/Server/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; namespace Duplicati.Server @@ -173,7 +174,7 @@ namespace Duplicati.Server { //If we are on Windows, append the bundled "win-tools" programs to the search path //We add it last, to allow the user to override with other versions - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + @@ -513,7 +514,7 @@ namespace Duplicati.Server //If you change the key, please note that you need to supply the same // key when restoring the setup, as the setup being backed up will // be encrypted as well. - if (!Library.Utility.Utility.IsClientLinux && string.IsNullOrEmpty(dbPassword)) + if (!Platform.IsClientLinux && string.IsNullOrEmpty(dbPassword)) dbPassword = Library.AutoUpdater.AutoUpdateSettings.AppName + "_Key_42"; // Allow override of the environment variables from the commandline @@ -552,7 +553,7 @@ namespace Duplicati.Server // serverDataFolder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Library.AutoUpdater.AutoUpdateSettings.AppName); - if (Duplicati.Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { var localappdata = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Library.AutoUpdater.AutoUpdateSettings.AppName); @@ -749,7 +750,7 @@ namespace Duplicati.Server }); - if (!Duplicati.Library.Utility.Utility.IsClientLinux) + if (!Platform.IsClientLinux) lst.Add(new Duplicati.Library.Interface.CommandLineArgument("server-encryption-key", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Password, Strings.Program.ServerencryptionkeyShort, Strings.Program.ServerencryptionkeyLong(DB_KEY_ENV_NAME, "unencrypted-database"), Library.AutoUpdater.AutoUpdateSettings.AppName + "_Key_42")); return lst.ToArray(); diff --git a/Duplicati/Server/SingleInstance.cs b/Duplicati/Server/SingleInstance.cs index aa52d2166..3c531d1b5 100644 --- a/Duplicati/Server/SingleInstance.cs +++ b/Duplicati/Server/SingleInstance.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Text; +using Duplicati.Library.Common; using Duplicati.Library.Common.IO; using Duplicati.Library.Utility; @@ -140,7 +141,7 @@ namespace Duplicati.Server try { - if (Library.Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) temp_fs = UnixSupport.File.OpenExclusive(m_lockfilename, System.IO.FileAccess.Write); else temp_fs = System.IO.File.Open(m_lockfilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None); @@ -188,7 +189,7 @@ namespace Duplicati.Server //HACK: the unix file lock does not allow us to read the file length when the file is locked if (new System.IO.FileInfo(m_lockfilename).Length == 0) - if (!Library.Utility.Utility.IsClientLinux) + if (!Platform.IsClientLinux) throw new Exception("The file was locked, but had no data"); //Notify the other process that we have started @@ -196,7 +197,7 @@ namespace Duplicati.Server //Write out the commandline arguments string[] cmdargs = System.Environment.GetCommandLineArgs(); - using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Library.Utility.Utility.IsClientLinux ? UnixSupport.File.OpenExclusive(filename, System.IO.FileAccess.Write) : new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.None))) + using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Platform.IsClientLinux ? UnixSupport.File.OpenExclusive(filename, System.IO.FileAccess.Write) : new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.None))) for (int i = 1; i < cmdargs.Length; i++) //Skip the first, as that is the filename sw.WriteLine(cmdargs[i]); @@ -237,7 +238,7 @@ namespace Duplicati.Server // needs a little time to create+lock the file. This is not really a fix, but an // ugly workaround. This functionality is only used to allow a new instance to signal // the running instance, so errors here would only affect that functionality - if (Library.Utility.Utility.IsClientLinux) + if (Platform.IsClientLinux) System.Threading.Thread.Sleep(1000); do @@ -249,7 +250,7 @@ namespace Duplicati.Server return; List args = new List(); - using (System.IO.StreamReader sr = new System.IO.StreamReader(Duplicati.Library.Utility.Utility.IsClientLinux ? UnixSupport.File.OpenExclusive(e.FullPath, System.IO.FileAccess.ReadWrite) : new System.IO.FileStream(e.FullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None))) + using (System.IO.StreamReader sr = new System.IO.StreamReader(Platform.IsClientLinux ? UnixSupport.File.OpenExclusive(e.FullPath, System.IO.FileAccess.ReadWrite) : new System.IO.FileStream(e.FullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None))) while(!sr.EndOfStream) args.Add(sr.ReadLine()); diff --git a/Duplicati/Server/SpecialFolders.cs b/Duplicati/Server/SpecialFolders.cs index 7c3334aa7..e95940d26 100644 --- a/Duplicati/Server/SpecialFolders.cs +++ b/Duplicati/Server/SpecialFolders.cs @@ -19,6 +19,7 @@ using System; using System.Linq; using System.Collections.Generic; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Server { @@ -113,7 +114,7 @@ namespace Duplicati.Server { var lst = new List(); - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { TryAdd(lst, Environment.SpecialFolder.MyDocuments, "%MY_DOCUMENTS%", "My Documents"); TryAdd(lst, Environment.SpecialFolder.MyMusic, "%MY_MUSIC%", "My Music"); diff --git a/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs b/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs index 8c346c72f..fb775b613 100644 --- a/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs +++ b/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs @@ -20,6 +20,7 @@ using System.Linq; using System.IO; using Duplicati.Library.Snapshots; using Duplicati.Library.Common.IO; +using Duplicati.Library.Common; namespace Duplicati.Server.WebServer.RESTMethods { @@ -67,7 +68,7 @@ namespace Duplicati.Server.WebServer.RESTMethods path = SpecialFolders.ExpandEnvironmentVariables(path); - if (Duplicati.Library.Utility.Utility.IsClientLinux && !path.StartsWith("/", StringComparison.Ordinal)) + if (Platform.IsClientLinux && !path.StartsWith("/", StringComparison.Ordinal)) { info.ReportClientError("The path parameter must start with a forward-slash", System.Net.HttpStatusCode.BadRequest); return; @@ -106,7 +107,7 @@ namespace Duplicati.Server.WebServer.RESTMethods IEnumerable res; - if (!Library.Utility.Utility.IsClientLinux && (path.Equals("/") || path.Equals(""))) + if (!Platform.IsClientLinux && (path.Equals("/") || path.Equals(""))) { res = DriveInfo.GetDrives() .Where(di => diff --git a/Duplicati/Server/WebServer/RESTMethods/HyperV.cs b/Duplicati/Server/WebServer/RESTMethods/HyperV.cs index 79640ff60..b5298eab9 100644 --- a/Duplicati/Server/WebServer/RESTMethods/HyperV.cs +++ b/Duplicati/Server/WebServer/RESTMethods/HyperV.cs @@ -20,7 +20,8 @@ using Duplicati.Library.Interface; using System.Linq; using System.Security.Principal; using Duplicati.Library.Snapshots; - +using Duplicati.Library.Common; + namespace Duplicati.Server.WebServer.RESTMethods { public class HyperV : IRESTMethodGET, IRESTMethodDocumented @@ -28,7 +29,7 @@ namespace Duplicati.Server.WebServer.RESTMethods public void GET(string key, RequestInfo info) { // Early exit in case we are non-windows to prevent attempting to load Windows-only components - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) RealGET(key, info); else info.OutputOK(new string[0]); diff --git a/Duplicati/Server/WebServer/RESTMethods/MSSQL.cs b/Duplicati/Server/WebServer/RESTMethods/MSSQL.cs index 910aa467e..2015fb959 100644 --- a/Duplicati/Server/WebServer/RESTMethods/MSSQL.cs +++ b/Duplicati/Server/WebServer/RESTMethods/MSSQL.cs @@ -20,7 +20,8 @@ using Duplicati.Library.Interface; using System.Linq; using System.Security.Principal; using Duplicati.Library.Snapshots; - +using Duplicati.Library.Common; + namespace Duplicati.Server.WebServer.RESTMethods { public class MSSQL : IRESTMethodGET, IRESTMethodDocumented @@ -28,7 +29,7 @@ namespace Duplicati.Server.WebServer.RESTMethods public void GET(string key, RequestInfo info) { // Early exit in case we are non-windows to prevent attempting to load Windows-only components - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) RealGET(key, info); else info.OutputOK(new string[0]); diff --git a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs index ac2232c3b..f16fe1da5 100644 --- a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs +++ b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs @@ -18,7 +18,8 @@ using System; using System.Linq; using System.Collections.Generic; using Duplicati.Library.Interface; - +using Duplicati.Library.Common; + namespace Duplicati.Server.WebServer.RESTMethods { public class SystemInfo : IRESTMethodGET, IRESTMethodPOST, IRESTMethodDocumented @@ -75,7 +76,7 @@ namespace Duplicati.Server.WebServer.RESTMethods DefaultUpdateChannel = Duplicati.Library.AutoUpdater.AutoUpdateSettings.DefaultUpdateChannel, DefaultUsageReportLevel = Duplicati.Library.UsageReporter.Reporter.DefaultReportLevel, ServerTime = DateTime.Now, - OSType = Library.Utility.Utility.IsClientLinux ? (Library.Utility.Utility.IsClientOSX ? "OSX" : "Linux") : "Windows", + OSType = Platform.IsClientLinux ? (Platform.IsClientOSX ? "OSX" : "Linux") : "Windows", DirectorySeparator = System.IO.Path.DirectorySeparatorChar, PathSeparator = System.IO.Path.PathSeparator, CaseSensitiveFilesystem = Duplicati.Library.Utility.Utility.IsFSCaseSensitive, diff --git a/Duplicati/UnitTest/IOTests.cs b/Duplicati/UnitTest/IOTests.cs index a8a6ee02c..b89e0f23b 100644 --- a/Duplicati/UnitTest/IOTests.cs +++ b/Duplicati/UnitTest/IOTests.cs @@ -20,6 +20,7 @@ using NUnit.Framework; using Duplicati.Library.Common.IO; using Duplicati.Library.Utility; +using Duplicati.Library.Common; namespace Duplicati.UnitTest { @@ -36,7 +37,7 @@ namespace Duplicati.UnitTest [Test] public void TestGetPathRootWithLongPath() { - var pathRoot = Utility.IsClientWindows ? "C:\\" : "/"; + var pathRoot = Platform.IsClientWindows ? "C:\\" : "/"; var root = SystemIO.IO_OS.GetPathRoot(LongPath(pathRoot)); Assert.AreEqual(pathRoot, root); @@ -45,7 +46,7 @@ namespace Duplicati.UnitTest [Test] public void TestUncBehaviourOfAlphaFS() { - if (!Utility.IsClientWindows) + if (!Platform.IsClientWindows) { return; } @@ -68,7 +69,7 @@ namespace Duplicati.UnitTest [Test] public void TestGetFilesWhenDirectoryDoesNotExist() { - var pathRoot = Utility.IsClientWindows ? "C:\\" : "/"; + var pathRoot = Platform.IsClientWindows ? "C:\\" : "/"; var longPath = LongPath(pathRoot); if (SystemIO.IO_OS.DirectoryExists(longPath)) @@ -83,7 +84,7 @@ namespace Duplicati.UnitTest [Test] public void TestGetDirectoriesWhenDirectoryDoesNotExist() { - var pathRoot = Utility.IsClientWindows ? "C:\\" : "/"; + var pathRoot = Platform.IsClientWindows ? "C:\\" : "/"; var longPath = LongPath(pathRoot); if (SystemIO.IO_OS.DirectoryExists(longPath)) diff --git a/Duplicati/UnitTest/RunScriptTests.cs b/Duplicati/UnitTest/RunScriptTests.cs index 28b39a91d..646f28c7d 100644 --- a/Duplicati/UnitTest/RunScriptTests.cs +++ b/Duplicati/UnitTest/RunScriptTests.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Duplicati.Library.Common; using Duplicati.Library.Interface; using NUnit.Framework; @@ -158,7 +159,7 @@ namespace Duplicati.UnitTest private string CreateScript(int exitcode, string stderr = null, string stdout = null, int sleeptime = 0) { var id = Guid.NewGuid().ToString("N").Substring(0, 6); - if (Library.Utility.Utility.IsClientWindows) + if (Platform.IsClientWindows) { var commands = new List(); if (!string.IsNullOrWhiteSpace(stdout))