Skip to content

Commit

Permalink
Added PushType in FileAdapter for DeleteThenCreate. Useful for Diffin…
Browse files Browse the repository at this point in the history
…g example scripts.
  • Loading branch information
alelom authored and al-fisher committed Apr 1, 2020
1 parent 91d6183 commit 95de665
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion File_Adapter/AdapterActions/Push.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override List<object> Push(IEnumerable<object> objects, string tag = "",
if (!ProcessExtension(ref m_FilePath))
return null;

CreateFileAndFolder();
CreateFileAndFolder(pushType);

if (objectsToPush.Count() != objects.Count())
Engine.Reflection.Compute.RecordWarning("The file adapter can currently only be used with BHoMObjects." + Environment.NewLine +
Expand Down
5 changes: 2 additions & 3 deletions File_Adapter/FileAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,13 @@ private bool ProcessExtension(ref string filePath)
return true;
}

private void CreateFileAndFolder()
private void CreateFileAndFolder(PushType pushType)
{
string directoryPath = Path.GetDirectoryName(m_FilePath);
if (!Directory.Exists(directoryPath))
Directory.CreateDirectory(directoryPath);


if (!File.Exists(m_FilePath))
if (!File.Exists(m_FilePath) || pushType == PushType.DeleteThenCreate)
{
FileStream stream = File.Create(m_FilePath);
stream.Dispose();
Expand Down

0 comments on commit 95de665

Please sign in to comment.