open_r.c

来自「FAT16 Filesystem on Philips LPC2000 seri」· C语言 代码 · 共 36 行

C
36
字号
#include <reent.h>#include <errno.h>#include <devices.h>#include <string.h>#include <sysdefs.h>int _open_r ( struct _reent *ptr, const char *file, int flags, int mode){#ifdef HAS_MMCint	i, len;		// all devices must start with a name and name is bracketed with '/'.	if (file[0] == '/') {			// we might have a valid device name, search the table list.		for (i=0; device_table_list [i].item; i++) {			len = strlen(device_table_list[i].item->name);			if (strncmp (device_table_list [i].item->name, &file[1], len) == 0) {					// ensure trailing '/'.				if (file[len+1] != '/') continue;					// found it, now call the open.					// device is called with device name removed.				if (device_table_list[i].item->open) {						// a function address appears to be there...					return device_table_list [i].item->open( ptr, &file[len+2], flags, mode);				}			}		}	}#endif		// otherwise we get nasty about it..	ptr->_errno = ENODEV;	return -1;}// vi:nowrap

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?