Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete several unused methods and types #405

Merged
merged 6 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions Scalar.Common/ConcurrentHashSet.cs

This file was deleted.

1 change: 0 additions & 1 deletion Scalar.Common/FileSystem/IPlatformFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public interface IPlatformFileSystem
void FlushFileBuffers(string path);
void MoveAndOverwriteFile(string sourceFileName, string destinationFilename);
bool TryGetNormalizedPath(string path, out string normalizedPath, out string errorMessage);
void ChangeMode(string path, ushort mode);
bool IsExecutable(string filePath);
bool IsSocket(string filePath);
bool TryCreateDirectoryWithAdminAndUserModifyPermissions(string directoryPath, out string error);
Expand Down
102 changes: 0 additions & 102 deletions Scalar.Common/FileSystem/PhysicalFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Security;
using System.Threading;
Expand Down Expand Up @@ -130,11 +129,6 @@ public virtual void MoveAndOverwriteFile(string sourceFileName, string destinati
ScalarPlatform.Instance.FileSystem.MoveAndOverwriteFile(sourceFileName, destinationFilename);
}

public virtual bool TryGetNormalizedPath(string path, out string normalizedPath, out string errorMessage)
{
return ScalarPlatform.Instance.FileSystem.TryGetNormalizedPath(path, out normalizedPath, out errorMessage);
}

public virtual Stream OpenFileStream(string path, FileMode fileMode, FileAccess fileAccess, FileShare shareMode, FileOptions options, bool callFlushFileBuffers)
{
if (callFlushFileBuffers)
Expand All @@ -145,11 +139,6 @@ public virtual Stream OpenFileStream(string path, FileMode fileMode, FileAccess
return new FileStream(path, fileMode, fileAccess, shareMode, DefaultStreamBufferSize, options);
}

public virtual void FlushFileBuffers(string path)
{
ScalarPlatform.Instance.FileSystem.FlushFileBuffers(path);
}

public virtual void CreateDirectory(string path)
{
Directory.CreateDirectory(path);
Expand All @@ -165,11 +154,6 @@ public virtual bool TryCreateOrUpdateDirectoryToAdminModifyPermissions(ITracer t
return ScalarPlatform.Instance.FileSystem.TryCreateOrUpdateDirectoryToAdminModifyPermissions(tracer, directoryPath, out error);
}

public virtual bool IsSymLink(string path)
{
return (this.GetAttributes(path) & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint && NativeMethods.IsSymLink(path);
}

public virtual IEnumerable<DirectoryItemInfo> ItemsInDirectory(string path)
{
DirectoryInfo ntfsDirectory = new DirectoryInfo(path);
Expand Down Expand Up @@ -201,24 +185,6 @@ public virtual IEnumerable<string> EnumerateFiles(string path, string searchPatt
return Directory.EnumerateFiles(path, searchPattern);
}

public virtual FileProperties GetFileProperties(string path)
{
FileInfo entry = new FileInfo(path);
if (entry.Exists)
{
return new FileProperties(
entry.Attributes,
entry.CreationTimeUtc,
entry.LastAccessTimeUtc,
entry.LastWriteTimeUtc,
entry.Length);
}
else
{
return FileProperties.DefaultFile;
}
}

public virtual FileAttributes GetAttributes(string path)
{
return File.GetAttributes(path);
Expand All @@ -229,31 +195,11 @@ public virtual void SetAttributes(string path, FileAttributes fileAttributes)
File.SetAttributes(path, fileAttributes);
}

public virtual void MoveFile(string sourcePath, string targetPath)
{
File.Move(sourcePath, targetPath);
}

public virtual string[] GetFiles(string directoryPath, string mask)
{
return Directory.GetFiles(directoryPath, mask);
}

public virtual FileVersionInfo GetVersionInfo(string path)
{
return FileVersionInfo.GetVersionInfo(path);
}

public virtual bool FileVersionsMatch(FileVersionInfo versionInfo1, FileVersionInfo versionInfo2)
{
return versionInfo1.FileVersion == versionInfo2.FileVersion;
}

public virtual bool ProductVersionsMatch(FileVersionInfo versionInfo1, FileVersionInfo versionInfo2)
{
return versionInfo1.ProductVersion == versionInfo2.ProductVersion;
}

public bool TryWriteTempFileAndRename(string destinationPath, string contents, out Exception handledException)
{
handledException = null;
Expand Down Expand Up @@ -291,54 +237,6 @@ public bool TryWriteTempFileAndRename(string destinationPath, string contents, o
}
}

public bool TryCopyToTempFileAndRename(string sourcePath, string destinationPath, out Exception handledException)
{
handledException = null;
string tempFilePath = destinationPath + ".temp";

try
{
File.Copy(sourcePath, tempFilePath, overwrite: true);
ScalarPlatform.Instance.FileSystem.FlushFileBuffers(tempFilePath);
this.MoveAndOverwriteFile(tempFilePath, destinationPath);
return true;
}
catch (Win32Exception e)
{
handledException = e;
return false;
}
catch (IOException e)
{
handledException = e;
return false;
}
catch (UnauthorizedAccessException e)
{
handledException = e;
return false;
}
}

public bool TryCreateDirectory(string path, out Exception exception)
{
try
{
Directory.CreateDirectory(path);
}
catch (Exception e) when (e is IOException ||
e is UnauthorizedAccessException ||
e is ArgumentException ||
e is NotSupportedException)
{
exception = e;
return false;
}

exception = null;
return true;
}

/// <summary>
/// Recursively deletes a directory and all contained contents.
/// </summary>
Expand Down
Loading