aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Common.Implementations')
-rw-r--r--Emby.Common.Implementations/BaseApplicationHost.cs6
-rw-r--r--Emby.Common.Implementations/IO/ManagedFileSystem.cs42
2 files changed, 25 insertions, 23 deletions
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs
index 9c9e14ec6b..87b97863bd 100644
--- a/Emby.Common.Implementations/BaseApplicationHost.cs
+++ b/Emby.Common.Implementations/BaseApplicationHost.cs
@@ -161,12 +161,6 @@ namespace Emby.Common.Implementations
/// <value>The name.</value>
public abstract string Name { get; }
- /// <summary>
- /// Gets a value indicating whether this instance is running as service.
- /// </summary>
- /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
- public abstract bool IsRunningAsService { get; }
-
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
protected IEnvironmentInfo EnvironmentInfo { get; private set; }
diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs
index 78070a5d91..3fe20f6596 100644
--- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs
@@ -20,10 +20,13 @@ namespace Emby.Common.Implementations.IO
private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
private bool EnableFileSystemRequestConcat = true;
- public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat)
+ private string _tempPath;
+
+ public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat, string tempPath)
{
Logger = logger;
_supportsAsyncFileStreams = supportsAsyncFileStreams;
+ _tempPath = tempPath;
EnableFileSystemRequestConcat = enableFileSystemRequestConcat;
SetInvalidFileNameChars(enableManagedInvalidFileNameChars);
}
@@ -487,18 +490,37 @@ namespace Emby.Common.Implementations.IO
throw new ArgumentNullException("file2");
}
- var temp1 = Path.GetTempFileName();
+ var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N"));
// Copying over will fail against hidden files
SetHidden(file1, false);
SetHidden(file2, false);
+ Directory.CreateDirectory(_tempPath);
CopyFile(file1, temp1, true);
CopyFile(file2, file1, true);
CopyFile(temp1, file2, true);
}
+ public bool AreEqual(string path1, string path2)
+ {
+ if (path1 == null && path2 == null)
+ {
+ return true;
+ }
+
+ if (path1 == null || path2 == null)
+ {
+ return false;
+ }
+
+ path1 = path1.TrimEnd(DirectorySeparatorChar);
+ path2 = path2.TrimEnd(DirectorySeparatorChar);
+
+ return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
+ }
+
public bool ContainsSubPath(string parentPath, string path)
{
if (string.IsNullOrEmpty(parentPath))
@@ -656,21 +678,7 @@ namespace Emby.Common.Implementations.IO
private IEnumerable<FileSystemMetadata> ToMetadata(string parentPath, IEnumerable<FileSystemInfo> infos)
{
- return infos.Select(i =>
- {
- try
- {
- return GetFileSystemMetadata(i);
- }
- catch (PathTooLongException)
- {
- // Can't log using the FullName because it will throw the PathTooLongExceptiona again
- //Logger.Warn("Path too long: {0}", i.FullName);
- Logger.Warn("File or directory path too long. Parent folder: {0}", parentPath);
- return null;
- }
-
- }).Where(i => i != null);
+ return infos.Select(GetFileSystemMetadata);
}
public string[] ReadAllLines(string path)