public void Apply()
{
if (!_fullPath.StartsWithIgnoreCase(_rootDirectory))
{
DeleteInsteadOfRename();
return;
}
var newDirectoryInfo = _fileSystem.GetDirectoryInfo(_fullPath);
var newRelativePath = PathHelper.EnsureTrailingSlash(PathHelper.MakeRelative(_rootDirectory, _fullPath));
if (!newDirectoryInfo.Exists || !_fileSystemFilter.IsDirectoryAllowed(newRelativePath, newDirectoryInfo.Attributes))
{
DeleteInsteadOfRename();
return;
}
var oldRelativePath = PathHelper.MakeRelative(_rootDirectory, _oldFullPath);
if (_entries.ContainsDirectoryEntry(oldRelativePath))
{
_entries.RenameDirectory(oldRelativePath, newRelativePath, _fileSystem.ToShortRelativePath(_fullPath, _rootDirectory));
}
else
{
(new DirectoryCreated(_entries, _rootDirectory, _fileSystem, _fileSystemFilter, _fullPath)).Apply();
}
}