예제 #1
0
        protected override Result DoOperateRange(Span <byte> outBuffer, OperationId operationId, long offset, long size, ReadOnlySpan <byte> inBuffer)
        {
            switch (operationId)
            {
            case OperationId.InvalidateCache:
            case OperationId.QueryRange:
                if (size == 0)
                {
                    if (operationId == OperationId.QueryRange)
                    {
                        if (outBuffer.Length != Unsafe.SizeOf <QueryRangeInfo>())
                        {
                            return(ResultFs.InvalidSize.Log());
                        }

                        Unsafe.As <byte, QueryRangeInfo>(ref outBuffer[0]) = new QueryRangeInfo();
                    }

                    return(Result.Success);
                }

                Result rc = UpdateSize();
                if (rc.IsFailure())
                {
                    return(rc);
                }

                if (size < 0 || offset < 0)
                {
                    return(ResultFs.OutOfRange.Log());
                }

                return(BaseFile.OperateRange(outBuffer, operationId, offset, size, inBuffer));

            default:
                return(ResultFs.UnsupportedOperateRangeForFileStorage.Log());
            }
        }