/// <summary>
        /// Ensure the prefetch pack with most-recent timestamp has an associated
        /// ".keep" file. This prevents any Git command from deleting the pack.
        ///
        /// Delete the previous ".keep" file(s) so that pack can be deleted when they
        /// are not the most-recent pack.
        /// </summary>
        private void UpdateKeepPacks()
        {
            if (!this.TryGetMaxGoodPrefetchTimestamp(out long maxGoodTimeStamp, out string error))
            {
                return;
            }

            string prefix = $"prefetch-{maxGoodTimeStamp}-";

            DirectoryItemInfo info = this.Context
                                     .FileSystem
                                     .ItemsInDirectory(this.Context.Enlistment.GitPackRoot)
                                     .Where(item => item.Name.StartsWith(prefix) &&
                                            string.Equals(Path.GetExtension(item.Name), ".pack", StringComparison.OrdinalIgnoreCase))
                                     .FirstOrDefault();

            if (info == null)
            {
                this.Context.Tracer.RelatedWarning(this.CreateEventMetadata(), $"Could not find latest prefetch pack, starting with {prefix}");
                return;
            }

            string newKeepFile = Path.ChangeExtension(info.FullName, ".keep");

            if (!this.Context.FileSystem.TryWriteAllText(newKeepFile, string.Empty))
            {
                this.Context.Tracer.RelatedWarning(this.CreateEventMetadata(), $"Failed to create .keep file at {newKeepFile}");
                return;
            }

            foreach (string keepFile in this.Context
                     .FileSystem
                     .ItemsInDirectory(this.Context.Enlistment.GitPackRoot)
                     .Where(item => item.Name.EndsWith(".keep"))
                     .Select(item => item.FullName))
            {
                if (!keepFile.Equals(newKeepFile))
                {
                    this.Context.FileSystem.TryDeleteFile(keepFile);
                }
            }
        }
        //public virtual bool TryCreateDirectoryWithAdminAndUserModifyPermissions(string directoryPath, out string error)
        //{
        //    return ScalarPlatform.Instance.FileSystem.TryCreateDirectoryWithAdminAndUserModifyPermissions(directoryPath, out error);
        //}

        //public virtual bool TryCreateOrUpdateDirectoryToAdminModifyPermissions( string directoryPath, out string error)
        //{
        //    return ScalarPlatform.Instance.FileSystem.TryCreateOrUpdateDirectoryToAdminModifyPermissions( directoryPath, out error);
        //}

        public virtual IEnumerable <DirectoryItemInfo> ItemsInDirectory(string path)
        {
            DirectoryInfo ntfsDirectory = new DirectoryInfo(path);

            foreach (FileSystemInfo ntfsItem in ntfsDirectory.GetFileSystemInfos())
            {
                DirectoryItemInfo itemInfo = new DirectoryItemInfo()
                {
                    FullName    = ntfsItem.FullName,
                    Name        = ntfsItem.Name,
                    IsDirectory = (ntfsItem.Attributes & FileAttributes.Directory) != 0
                };

                if (!itemInfo.IsDirectory)
                {
                    itemInfo.Length = ((FileInfo)ntfsItem).Length;
                }

                yield return(itemInfo);
            }
        }