2020-08-27 00:21:44 +08:00
|
|
|
// Copyright (c) 2018-2019 HALX99
|
|
|
|
// Copyright (c) 2020 c4games.com
|
2019-11-24 14:54:45 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2021-04-22 22:01:32 +08:00
|
|
|
#include "platform/CCPlatformConfig.h"
|
2019-11-24 14:54:45 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2020-08-27 00:21:44 +08:00
|
|
|
class CC_DLL FileStream {
|
2019-11-24 14:54:45 +08:00
|
|
|
public:
|
2021-04-22 19:49:43 +08:00
|
|
|
virtual ~FileStream() = default;
|
2020-08-27 11:35:55 +08:00
|
|
|
|
2020-08-27 10:19:21 +08:00
|
|
|
enum class Mode {
|
|
|
|
READ,
|
|
|
|
WRITE,
|
|
|
|
APPEND,
|
2019-11-24 14:54:45 +08:00
|
|
|
};
|
|
|
|
|
2021-04-24 07:22:27 +08:00
|
|
|
virtual bool open(const std::string& path, FileStream::Mode mode) = 0;
|
2021-04-22 19:49:43 +08:00
|
|
|
virtual int close() = 0;
|
|
|
|
|
|
|
|
virtual int seek(long offset, int origin) = 0;
|
|
|
|
virtual int read(void* buf, unsigned int size) = 0;
|
|
|
|
|
|
|
|
virtual int write(const void* buf, unsigned int size) = 0;
|
|
|
|
virtual int tell() = 0;
|
|
|
|
virtual bool isOpen() const = 0;
|
2021-04-24 07:22:27 +08:00
|
|
|
|
|
|
|
virtual operator bool() const { return isOpen(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FileStream() = default;
|
2021-04-22 19:49:43 +08:00
|
|
|
};
|
|
|
|
|
2019-11-24 14:54:45 +08:00
|
|
|
NS_CC_END
|