// Copyright (c) 2018-2019 HALX99 // Copyright (c) 2020 c4games.com #pragma once #include "platform/CCPlatformConfig.h" #include #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include #include #else #include #include #endif #include #include #include "platform/CCPlatformMacros.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #include "platform/android/CCFileUtils-android.h" #include #include #include #include "base/ZipUtils.h" #endif NS_CC_BEGIN struct UnzFileStream; union PXFileHandle { int _fd = -1; #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID AAsset* _asset; ZipFileStream _zfs; #endif }; struct PXIoF; class CC_DLL FileStream { public: FileStream(); ~FileStream(); FileStream(FileStream&& rhs); FileStream& operator=(FileStream&& rhs); enum class Mode { READ, WRITE, APPEND, }; bool open(const std::string& path, Mode mode); int close(); int seek(long offset, int origin); int read(void* buf, unsigned int size); int write(const void* buf, unsigned int size); operator bool() const; private: void zeroset(); void assign(FileStream&& rhs); PXFileHandle _handle; const PXIoF* _iof; }; NS_CC_END