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

Adding Delete in IFileSystem #2072

Merged
merged 5 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions src/Sarif/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,16 @@ public void DeleteDirectory(string path, bool recursive = false)
{
Directory.Delete(path, recursive);
}

/// <summary>
/// Deletes the specified file.
/// </summary>
/// <param name="path">
/// The name of the file to be deleted. Wildcard characters are not supported.
/// </param>
public void DeleteFile(string path)
Copy link
Member

@michaelcfanning michaelcfanning Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeleteFile [](start = 20, length = 10)

Generally, we want these names to match the corresponding system API. In this case, we have a problem: Delete is shared as a name between multiple types. I suggest that we prefix Delete with that enclosing type name. So this method s/be named 'FileDelete' and the one preceding it s/be named 'DirectoryDelete' #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename the method CreateDirectory as well?


In reply to: 496997632 [](ancestors = 496997632)

Copy link
Member

@michaelcfanning michaelcfanning Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, to be consistent,this looks right. I think that also means we need to rename 'Create' to 'FileCreate', since it maps to File.Create? Nice catch!


In reply to: 497004102 [](ancestors = 497004102,496997632)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated both


In reply to: 497005275 [](ancestors = 497005275,497004102,496997632)

{
File.Delete(path);
}
}
}
8 changes: 8 additions & 0 deletions src/Sarif/IFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,13 @@ public interface IFileSystem
/// The name of the empty directory to remove. This directory must be writable and empty.
/// </param>
void DeleteDirectory(string path, bool recursive = false);

/// <summary>
/// Deletes the specified file.
/// </summary>
/// <param name="path">
/// The name of the file to be deleted. Wildcard characters are not supported.
/// </param>
void DeleteFile(string path);
}
}