Example #1
0
        private Result WriteFile(ReadOnlySpan <byte> data)
        {
            Debug.Assert(FsClient != null);
            Debug.Assert(!string.IsNullOrWhiteSpace(FileName));

            FsClient.DeleteFile(FileName);

            Result rc = FsClient.CreateFile(FileName, data.Length);

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = FsClient.OpenFile(out FileHandle handle, FileName, OpenMode.Write);
            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = FsClient.WriteFile(handle, 0, data, WriteOption.Flush);
            FsClient.CloseFile(handle);

            return(rc);
        }