Skip to content

Commit

Permalink
Merge pull request #405: Delete several unused methods and types
Browse files Browse the repository at this point in the history
When we forked the code from VFS for Git we brought over a lot of things that are not required. We're still carrying them around and they should be removed - we have no use for them and will not need them.

In many cases the only 'references' to these types were either themselves, or their own unit tests.
  • Loading branch information
mjcheetham authored Jul 15, 2020
2 parents 5711fca + 47ed0fe commit 92ce2e9
Show file tree
Hide file tree
Showing 28 changed files with 4 additions and 2,463 deletions.
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

0 comments on commit 92ce2e9

Please sign in to comment.