2021-09-06 10:58:08 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AFIO.hpp
|
|
|
|
Date: 2021-8-21
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
namespace Aurora::IO::FS
|
2021-09-06 10:58:08 +00:00
|
|
|
{
|
|
|
|
class IAsyncTransaction;
|
|
|
|
|
|
|
|
class IAsyncFileStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual AuSPtr<IAsyncTransaction> NewTransaction() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAsyncFinishedSubscriber
|
|
|
|
{
|
|
|
|
public:
|
2021-09-13 20:11:12 +00:00
|
|
|
virtual void OnAsyncFileOpFinished(AuUInt64 offset, AuUInt32 length) = 0;
|
2021-09-06 10:58:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IAsyncTransaction
|
|
|
|
{
|
|
|
|
public:
|
2021-09-13 20:11:12 +00:00
|
|
|
virtual bool StartRead(AuUInt64 offset, void *, AuUInt32 length) = 0;
|
|
|
|
virtual bool StartWrite(AuUInt64 offset, const void *, AuUInt32 length) = 0;
|
2021-09-06 10:58:08 +00:00
|
|
|
|
|
|
|
virtual bool Complete() = 0;
|
|
|
|
virtual AuUInt32 GetLastPacketLength() = 0;
|
|
|
|
|
|
|
|
virtual void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) = 0;
|
|
|
|
|
|
|
|
virtual void Wait(AuUInt32 timeout) = 0;
|
|
|
|
};
|
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
AUKN_SHARED_API(OpenAsync, IAsyncFileStream, const AuString &path, bool readOnly = true, bool directIO = false);
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
AUKN_SYM bool WaitMultiple(const AuList<IAsyncTransaction> &files, AuUInt32 timeout);
|
2021-09-06 10:58:08 +00:00
|
|
|
}
|