// Copyright (c) 2018-2019 HALX99, TODO: may rename this file to PXFileStream #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 PXFileStream { public: PXFileStream(); ~PXFileStream(); enum Mode { kModeReadOnly, kModeWrite, kModeAppend, }; bool open(const std::string& path, int mode = kModeReadOnly); 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: PXFileHandle _handle; const PXIoF* _iof; }; NS_CC_END