百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

memorymapping

> 编程语言
开源

用于 iOS 和 Mac OS X 的 fmemopen 端口

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于 iOS 和 Mac OS X 的 fmemopen 端口

fmemopen for Mac OS and iOS

Originally ported from ingenuitas python-tesseract. Ported by Jeff Verkoeyen under the Apache 2.0 License.

From the fmemopen man page:

FILE *fmemopen(void *buf, size_t size, const char *mode);

The fmemopen() function opens a stream that permits the access specified by mode. The stream allows I/O to be performed on the string or memory buffer pointed to by buf. This buffer must be at least size bytes long.

Alas, this method does not exist on BSD operating systems (specifically Mac OS X and iOS). It is possible to recreate this functionality using a BSD-specific method called funopen.

From the funopen man page:

FILE * funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));

The funopen() function associates a stream with up to four ``I/O functions''. Either readfn or writefn must be specified; the others can be given as an appropriately-typed NULL pointer. These I/O functions will be used to read, write, seek and close the new stream.

fmemopen.c provides a simple implementation of fmemopen using funopen so that you can create FILE pointers to blocks of memory.

Adding it to your Project

Drag fmemopen.h and fmemopen.c to your project and add them to your target. #include "fmemopen.h" wherever you need to use fmemopen.

Examples

obj-c
#import "fmemopen.h"

NSString* string = @"fmemopen in Objective-C";
const char* cstr = [string UTF8String];
FILE* file = fmemopen((void *)cstr, sizeof(char) * (string.length + 1), "r");

// fread on file will now read the contents of the NSString

fclose(file);

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言