📄 defaultfilesystem.cpp
字号:
#include <stdio.h>
#include "Utility.h"
namespace corona {
class CFile : public DLLImplementation<File> {
public:
CFile(FILE* file) {
m_file = file;
}
~CFile() {
fclose(m_file);
}
int COR_CALL read(void* buffer, int size) {
return fread(buffer, 1, size, m_file);
}
int COR_CALL write(const void* buffer, int size) {
return fwrite(buffer, 1, size, m_file);
}
bool COR_CALL seek(int position, SeekMode mode) {
int m;
switch (mode) {
case BEGIN: m = SEEK_SET; break;
case CURRENT: m = SEEK_CUR; break;
case END: m = SEEK_END; break;
default: return false;
}
return fseek(m_file, position, m) == 0;
}
int COR_CALL tell() {
return ftell(m_file);
}
private:
FILE* m_file;
};
COR_EXPORT(File*) CorOpenFile(const char* filename, bool writeable) {
FILE* file = fopen(filename, (writeable ? "wb" : "rb"));
return (file ? new CFile(file) : 0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -