#pragma once
#include "Error.h"
#include "fs/Api.h"
#include "fs/AbsPath.h"

namespace fs
{
//////////////////////////////////////////////////////////////////////////

class IStreamSource;
class IFilesystem;

FS_API uint32_t computeCRC32(uint32_t crc, tl::span<const uint8_t> data);
FS_API uint64_t computeCRC64(uint64_t crc, tl::span<const uint8_t> data);

typedef tl::result<uint32_t, Error> CRC32StreamResult;
FS_API CRC32StreamResult crc32Stream(IStreamSource& source, uint32_t crc = 0, size_t bufferSize = 0);
FS_API CRC32StreamResult crc32File(const IFilesystem& filesystem, AbsPathView filePath, uint32_t crc = 0, size_t bufferSize = 0);

typedef tl::result<uint64_t, Error> CRC64StreamResult;
FS_API CRC64StreamResult crc64Stream(IStreamSource& source, uint64_t crc = 0, size_t bufferSize = 0);
FS_API CRC64StreamResult crc64File(const IFilesystem& filesystem, AbsPathView filePath, uint64_t crc = 0, size_t bufferSize = 0);

//////////////////////////////////////////////////////////////////////////
}
