From f4c338c63f3456a8eccd56c35e233843687d55be Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 00:43:25 +0800 Subject: *thread --- source/libs/asura-lib-utils/io/file.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/libs/asura-lib-utils/io/file.cpp') diff --git a/source/libs/asura-lib-utils/io/file.cpp b/source/libs/asura-lib-utils/io/file.cpp index 976203d..0ff8c90 100644 --- a/source/libs/asura-lib-utils/io/file.cpp +++ b/source/libs/asura-lib-utils/io/file.cpp @@ -134,7 +134,10 @@ namespace AsuraEngine if (length < 0) throw Exception("Invalid read size."); - return PHYSFS_readBytes(mFileHandle, dst->GetData(), length); + dst->Lock(); + size_t size = PHYSFS_readBytes(mFileHandle, dst->GetData(), length); + dst->Unlock(); + return size; } size_t File::ReadAll(ASURA_OUT DataBuffer* dst) @@ -149,7 +152,10 @@ namespace AsuraEngine if (dst->GetSize() < length) throw Exception("Data buffer is too small compares to file length."); - return PHYSFS_readBytes(mFileHandle, dst->GetData(), length); + dst->Lock(); + size_t size = PHYSFS_readBytes(mFileHandle, dst->GetData(), length); + dst->Unlock(); + return size; } #ifdef ASURA_WINDOWS -- cgit v1.1-26-g67d0