⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultfilesystem.cpp

📁 这个刚才那个的源代码
💻 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 + -