Beispiel #1
0
int EbrOpenWithPermission(const char* file, int mode, int share, int pmode) {
    if (strcmp(file, "/dev/urandom") == 0) {
        EbrFileDevRandom* ret = new EbrFileDevRandom();
        EbrFile* addedFile = EbrAllocFile(ret);

        return addedFile->idx;
    }

    bool stop = false;
    if (stop) {
        return -1;
    }
    int ret = -1;
    _sopen_s(&ret, CPathMapper(file), mode, share, pmode);
    if (ret == -1) {
        return -1;
    }

    EbrIOFile* newFile = new EbrIOFile();
    newFile->filefd = ret;

    EbrFile* addedFile = EbrAllocFile(newFile);

    return addedFile->idx;
}
EbrFile* EbrFreopen(const char* filename, const char* mode, EbrFile* cur) {
    FILE* fp = NULL;

    freopen_s(&fp, CPathMapper(filename), mode, ((EbrIOFile*)cur)->fp);
    if (!fp)
        return NULL;

    EbrIOFile* ret = new EbrIOFile();
    ret->fp = fp;
    ret->filefd = _fileno(fp);

    return EbrAllocFile(ret);
}
EbrFile* EbrFopen(const char* filename, const char* mode) {
    if (strcmp(filename, "/dev/urandom") == 0) {
        EbrFileDevRandom* ret = new EbrFileDevRandom();
        return EbrAllocFile(ret);
    }
    bool stop = false;
    if (stop) {
        return NULL;
    }
    FILE* fp;
    fopen_s(&fp, CPathMapper(filename), mode);
    if (!fp) {
        return NULL;
    }

    EbrIOFile* ret = new EbrIOFile();
    ret->fp = fp;
    ret->filefd = _fileno(fp);
    return EbrAllocFile(ret);
}
bool EbrMkdir(const char* path) {
    return _mkdir(CPathMapper(path)) == 0;
}
bool EbrUnlink(const char* path) {
    return _unlink(CPathMapper(path)) == 0;
}
bool EbrRename(const char* path1, const char* path2) {
    return rename(CPathMapper(path1), CPathMapper(path2)) == 0;
}
bool EbrRemoveEmptyDir(const char* path) {
    return RemoveDirectoryA(CPathMapper(path));
}