Skip to content

Commit

Permalink
[Editor API] - Added function to tell if a directory is excluded from…
Browse files Browse the repository at this point in the history
… pack file output.
  • Loading branch information
Tape-Worm committed Sep 21, 2021
1 parent eb34774 commit 2a9c263
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ string CurrentDirectory
#endregion

#region Methods.
/// <summary>
/// Function to determine if a directory is excluded from a packed file.
/// </summary>
/// <param name="directory">Path to the directory to evaluate.</param>
/// <returns><b>true</b> if excluded, <b>false</b> if not.</returns>
bool IsDirectoryExcluded(string directory);

/// <summary>
/// Function to create a new directory
/// </summary>
Expand Down
41 changes: 41 additions & 0 deletions Tools/Editor/Gorgon.Editor/FileSystem/ViewModels/FileExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3513,6 +3513,47 @@ void UpdateUI(object context)
/// </summary>
/// <returns>The <see cref="IGorgonFileSystem"/> for this content manager.</returns>
IGorgonFileSystem IContentFileManager.ToGorgonFileSystem() => _fileSystemWriter.FileSystem;

/// <summary>
/// Function to determine if a directory is excluded from a packed file.
/// </summary>
/// <param name="directory">Path to the directory to evaluate.</param>
/// <returns><b>true</b> if excluded, <b>false</b> if not.</returns>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="directory"/> parameter is <b>null</b>.</exception>
/// <exception cref="ArgumentEmptyException">Thrown when the <paramref name="directory"/> parameter is empty.</exception>
/// <exception cref="DirectoryNotFoundException">Thrown if the directory does not exist.</exception>
bool IContentFileManager.IsDirectoryExcluded(string directory)
{
if (directory is null)
{
throw new ArgumentNullException(nameof(directory));
}

if (string.IsNullOrWhiteSpace(directory))
{
throw new ArgumentEmptyException(nameof(directory));
}

directory = directory.FormatDirectory('/');

if (!directory.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{

directory = "/" + directory;
}

if (!_directories.TryGetValue(directory, out IDirectory dir))
{
throw new DirectoryNotFoundException(string.Format(Resources.GOREDIT_ERR_DIRECTORY_NOT_FOUND, directory));
}

if (dir is not IExcludable excluder)
{
return false;
}

return excluder.IsExcluded;
}
#endregion

#region Constructor/Finalizer.
Expand Down

0 comments on commit 2a9c263

Please sign in to comment.