mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-08 23:00:51 +02:00
update directory picker
This commit is contained in:
parent
733b891f52
commit
6e4d234212
|
@ -69,14 +69,6 @@ namespace Emby.Common.Implementations.IO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public char PathSeparator
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Path.PathSeparator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetFullPath(string path)
|
public string GetFullPath(string path)
|
||||||
{
|
{
|
||||||
return Path.GetFullPath(path);
|
return Path.GetFullPath(path);
|
||||||
|
@ -544,6 +536,16 @@ namespace Emby.Common.Implementations.IO
|
||||||
CopyFile(temp1, file2, true);
|
CopyFile(temp1, file2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private char GetSeparatorChar(string path)
|
||||||
|
{
|
||||||
|
if (path.IndexOf('/') != -1)
|
||||||
|
{
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
|
||||||
public bool AreEqual(string path1, string path2)
|
public bool AreEqual(string path1, string path2)
|
||||||
{
|
{
|
||||||
if (path1 == null && path2 == null)
|
if (path1 == null && path2 == null)
|
||||||
|
@ -556,8 +558,8 @@ namespace Emby.Common.Implementations.IO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
path1 = path1.TrimEnd(DirectorySeparatorChar);
|
path1 = path1.TrimEnd(GetSeparatorChar(path1));
|
||||||
path2 = path2.TrimEnd(DirectorySeparatorChar);
|
path2 = path2.TrimEnd(GetSeparatorChar(path2));
|
||||||
|
|
||||||
return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
|
return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
@ -574,7 +576,9 @@ namespace Emby.Common.Implementations.IO
|
||||||
throw new ArgumentNullException("path");
|
throw new ArgumentNullException("path");
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.IndexOf(parentPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) != -1;
|
var separatorChar = GetSeparatorChar(parentPath);
|
||||||
|
|
||||||
|
return path.IndexOf(parentPath.TrimEnd(separatorChar) + separatorChar, StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRootPath(string path)
|
public bool IsRootPath(string path)
|
||||||
|
@ -606,7 +610,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.TrimEnd(Path.DirectorySeparatorChar);
|
return path.TrimEnd(GetSeparatorChar(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFileNameWithoutExtension(FileSystemMetadata info)
|
public string GetFileNameWithoutExtension(FileSystemMetadata info)
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
private string GetReturnPath(SmbFile file)
|
private string GetReturnPath(SmbFile file)
|
||||||
{
|
{
|
||||||
return file.GetCanonicalPath();
|
return file.GetCanonicalPath().TrimEnd('/');
|
||||||
//return file.GetPath();
|
//return file.GetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,9 +419,16 @@ namespace Emby.Common.Implementations.IO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SmbFile CreateSmbDirectoryForListFiles(string path)
|
||||||
|
{
|
||||||
|
// In order to call ListFiles, it has to end with the separator
|
||||||
|
|
||||||
|
return CreateSmbFile(path.TrimEnd('/') + '/');
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false)
|
public IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
@ -437,7 +444,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
public IEnumerable<FileSystemMetadata> GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
public IEnumerable<FileSystemMetadata> GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
@ -459,7 +466,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false)
|
public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
@ -472,7 +479,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
public IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false)
|
public IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
@ -485,7 +492,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
public IEnumerable<string> GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
public IEnumerable<string> GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
@ -507,7 +514,7 @@ namespace Emby.Common.Implementations.IO
|
||||||
|
|
||||||
public IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false)
|
public IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false)
|
||||||
{
|
{
|
||||||
var dir = CreateSmbFile(path);
|
var dir = CreateSmbDirectoryForListFiles(path);
|
||||||
AssertDirectoryExists(dir, path);
|
AssertDirectoryExists(dir, path);
|
||||||
|
|
||||||
var list = ListFiles(dir, recursive);
|
var list = ListFiles(dir, recursive);
|
||||||
|
|
|
@ -273,11 +273,20 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
return 400;
|
return 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var exceptionType = ex.GetType();
|
||||||
|
|
||||||
int statusCode;
|
int statusCode;
|
||||||
if (!_mapExceptionToStatusCode.TryGetValue(ex.GetType(), out statusCode))
|
if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode))
|
||||||
|
{
|
||||||
|
if (string.Equals(exceptionType.Name, "DirectoryNotFoundException", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
statusCode = 404;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
statusCode = 500;
|
statusCode = 500;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return statusCode;
|
return statusCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,6 @@ namespace MediaBrowser.Model.IO
|
||||||
void SetReadOnly(string path, bool isHidden);
|
void SetReadOnly(string path, bool isHidden);
|
||||||
|
|
||||||
char DirectorySeparatorChar { get; }
|
char DirectorySeparatorChar { get; }
|
||||||
char PathSeparator { get; }
|
|
||||||
|
|
||||||
string GetFullPath(string path);
|
string GetFullPath(string path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue