diff options
author | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
commit | f4c338c63f3456a8eccd56c35e233843687d55be (patch) | |
tree | 7278fe4723320c9ef310c5a04d92bf0be1bc778c /source/libs/asura-lib-utils/io/file.cpp | |
parent | 3bced067a4144381e59ce4bd0eb749eeff5ad1f4 (diff) |
*thread
Diffstat (limited to 'source/libs/asura-lib-utils/io/file.cpp')
-rw-r--r-- | source/libs/asura-lib-utils/io/file.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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 |