[+] AuFS::OpenAsyncFromSharedHandle
This commit is contained in:
parent
48aa0f01b1
commit
a9fd9221b7
@ -12,13 +12,9 @@ namespace Aurora::IO::FS
|
|||||||
AUKN_SHARED_API(OpenAsync, IAsyncFileStream,
|
AUKN_SHARED_API(OpenAsync, IAsyncFileStream,
|
||||||
const AuString &path,
|
const AuString &path,
|
||||||
EFileOpenMode openMode,
|
EFileOpenMode openMode,
|
||||||
bool bDirectIO = true, // true disables buffering under Win32
|
AuOptional<bool> optbDirectIO = { true },
|
||||||
// true enables non-blocking ticks under Linux aio by bypassing the kernels cache
|
AuOptional<EFileAdvisoryLockLevel> optLock = { EFileAdvisoryLockLevel::eNoSafety });
|
||||||
EFileAdvisoryLockLevel lock = EFileAdvisoryLockLevel::eNoSafety);
|
|
||||||
|
|
||||||
#if defined(AUX_FSAOPEX)
|
AUKN_SHARED_API(OpenAsyncFromSharedHandle, IAsyncFileStream,
|
||||||
AUKN_SYM AuSPtr<IAsyncTransaction> OpenDirectIOAsyncFileStreamFromHandle(AuSPtr<IIOHandle> pIOHandle);
|
const AuSPtr<IIOHandle> &pIOHandle);
|
||||||
|
|
||||||
AUKN_SYM AuSPtr<IAsyncTransaction> OpenBufferedAsyncFileStreamFromHandle(AuSPtr<IIOHandle> pIOHandle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
@ -611,8 +611,11 @@ namespace Aurora::IO::FS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, bool bDirectIO, EFileAdvisoryLockLevel lock)
|
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
|
||||||
{
|
{
|
||||||
|
auto bDirectIO = optbDirectIO.ValueOr(true);
|
||||||
|
auto lock = optLock.ValueOr(EFileAdvisoryLockLevel::eNoSafety);
|
||||||
|
|
||||||
auto pHandle = AuIO::IOHandleShared();
|
auto pHandle = AuIO::IOHandleShared();
|
||||||
if (!pHandle)
|
if (!pHandle)
|
||||||
{
|
{
|
||||||
@ -648,4 +651,22 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
AuSafeDelete<LinuxAsyncFileStream *>(handle);
|
AuSafeDelete<LinuxAsyncFileStream *>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AUKN_SYM IAsyncFileStream *OpenAsyncFromSharedHandleNew(const AuSPtr<IIOHandle> &pIOHandle)
|
||||||
|
{
|
||||||
|
auto pStream = _new LinuxAsyncFileStream();
|
||||||
|
if (!pStream)
|
||||||
|
{
|
||||||
|
SysPushErrorMemory();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStream->Init(pIOHandle);
|
||||||
|
return pStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
AUKN_SYM void OpenAsyncFromSharedHandleRelease(IAsyncFileStream *handle)
|
||||||
|
{
|
||||||
|
AuSafeDelete<LinuxAsyncFileStream *>(handle);
|
||||||
|
}
|
||||||
}
|
}
|
@ -667,8 +667,11 @@ namespace Aurora::IO::FS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, bool directIO, EFileAdvisoryLockLevel lock)
|
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
|
||||||
{
|
{
|
||||||
|
auto bDirectIO = optbDirectIO.ValueOr(true);
|
||||||
|
auto lock = optLock.ValueOr(EFileAdvisoryLockLevel::eNoSafety);
|
||||||
|
|
||||||
auto pHandle = AuIO::IOHandleShared();
|
auto pHandle = AuIO::IOHandleShared();
|
||||||
if (!pHandle)
|
if (!pHandle)
|
||||||
{
|
{
|
||||||
@ -680,7 +683,7 @@ namespace Aurora::IO::FS
|
|||||||
createhandle.eAdvisoryLevel = lock;
|
createhandle.eAdvisoryLevel = lock;
|
||||||
createhandle.eMode = openMode;
|
createhandle.eMode = openMode;
|
||||||
createhandle.bFailIfNonEmptyFile = false;
|
createhandle.bFailIfNonEmptyFile = false;
|
||||||
createhandle.bDirectIOMode = directIO;
|
createhandle.bDirectIOMode = bDirectIO;
|
||||||
createhandle.bAsyncHandle = true;
|
createhandle.bAsyncHandle = true;
|
||||||
|
|
||||||
if (!pHandle->InitFromPath(createhandle))
|
if (!pHandle->InitFromPath(createhandle))
|
||||||
@ -704,4 +707,22 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
AuSafeDelete<NtAsyncFileStream *>(handle);
|
AuSafeDelete<NtAsyncFileStream *>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AUKN_SYM IAsyncFileStream *OpenAsyncFromSharedHandleNew(const AuSPtr<IIOHandle> &pIOHandle)
|
||||||
|
{
|
||||||
|
auto pStream = _new NtAsyncFileStream();
|
||||||
|
if (!pStream)
|
||||||
|
{
|
||||||
|
SysPushErrorMemory();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStream->Init(pIOHandle);
|
||||||
|
return pStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
AUKN_SYM void OpenAsyncFromSharedHandleRelease(IAsyncFileStream *handle)
|
||||||
|
{
|
||||||
|
AuSafeDelete<NtAsyncFileStream *>(handle);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user