all repos — mgba @ d1ef27cff90eda02bde9f90cc526e901a4c81d83

mGBA Game Boy Advance Emulator

src/platform/python/vfs-py.c (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "vfs-py.h"
 7
 8struct VFile* VFileFromPython(void* fileobj) {
 9	if (!fileobj) {
10		return 0;
11	}
12
13	struct VFilePy* vfp = malloc(sizeof(struct VFilePy));
14	if (!vfp) {
15		return 0;
16	}
17
18	vfp->fileobj = fileobj;
19	vfp->d.close = _vfpClose;
20	vfp->d.seek = _vfpSeek;
21	vfp->d.read = _vfpRead;
22	vfp->d.readline = VFileReadline;
23	vfp->d.write = _vfpWrite;
24	vfp->d.map = _vfpMap;
25	vfp->d.unmap = _vfpUnmap;
26	vfp->d.truncate = _vfpTruncate;
27	vfp->d.size = _vfpSize;
28	vfp->d.sync = _vfpSync;
29
30	return &vfp->d;
31}