mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
@@ -4,18 +4,27 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public class FileVersionInfoWrapper : IFileVersionInfoWrapper
|
||||
{
|
||||
private readonly IFile _file;
|
||||
|
||||
public FileVersionInfoWrapper()
|
||||
: this(new FileSystem().File)
|
||||
{
|
||||
}
|
||||
|
||||
public FileVersionInfoWrapper(IFile file)
|
||||
{
|
||||
_file = file;
|
||||
}
|
||||
|
||||
public FileVersionInfo GetVersionInfo(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
if (_file.Exists(path))
|
||||
{
|
||||
return FileVersionInfo.GetVersionInfo(path);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public class FileWrapper : IFileWrapper
|
||||
{
|
||||
public FileWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
public string[] ReadAllLines(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.ReadAllLines(path);
|
||||
}
|
||||
catch (System.Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException || ex is IOException)
|
||||
{
|
||||
Log.Info($"Unable to read File: {path}| {ex.Message}", GetType());
|
||||
|
||||
return new string[] { string.Empty };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public interface IFileWrapper
|
||||
{
|
||||
string[] ReadAllLines(string path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user