#pragma warning restore CS0612 // 型またはメンバーが旧型式です protected override async Task SetFileSizeImplAsync(long size, CancellationToken cancel = default) { List <Cursor> cursorList = GenerateCursorList(size, 1, true); Cursor cursor = cursorList.Single(); bool shrink = (this.CurrentFileSize > size); if (shrink) { // Delete oversized files LargeFileSystem.ParsedPath[] physicalFiles = await LargeFileSystem.GetPhysicalFileStateInternal(this.FileParams.Path, cancel); List <LargeFileSystem.ParsedPath> filesToDelete = physicalFiles.Where(x => x.FileNumber > cursor.PhysicalFileNumber).ToList(); await LargeFileSystem.UnderlayFileSystemPoolForWrite.EnumAndCloseHandlesAsync((key, file) => { if (filesToDelete.Where(x => x.PhysicalFilePath._IsSame(file.FileParams.Path, LargeFileSystem.PathParser.PathStringComparison)).Any()) { return(true); } return(false); }, () => { foreach (LargeFileSystem.ParsedPath deleteFile in filesToDelete.OrderByDescending(x => x.PhysicalFilePath)) { UnderlayFileSystem.DeleteFile(deleteFile.PhysicalFilePath, FileFlags.ForceClearReadOnlyOrHiddenBitsOnNeed, cancel); } }, (x, y) => { return(-(x.FileParams.Path.CompareTo(y.FileParams.Path))); }, cancel); await LargeFileSystem.UnderlayFileSystemPoolForWrite.EnumAndCloseHandlesAsync((key, file) => { if (filesToDelete.Where(x => x.PhysicalFilePath._IsSame(file.FileParams.Path, LargeFileSystem.PathParser.PathStringComparison)).Any()) { return(true); } return(false); }, () => { foreach (LargeFileSystem.ParsedPath deleteFile in filesToDelete.OrderByDescending(x => x.PhysicalFilePath)) { UnderlayFileSystem.DeleteFile(deleteFile.PhysicalFilePath, FileFlags.ForceClearReadOnlyOrHiddenBitsOnNeed, cancel); } }, (x, y) => { return(-(x.FileParams.Path.CompareTo(y.FileParams.Path))); }, cancel); } await using (var handle = await GetUnderlayRandomAccessHandle(cursor.LogicalPosition, cancel)) { await handle.SetFileSizeAsync(cursor.PhysicalPosition, cancel); this.CurrentFileSize = size; } }