亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tff.c

?? thenewofTiny-FatFs
?? C
?? 第 1 頁 / 共 4 頁
字號:

/*-----------------------------------------------------------------------*/
/* Open or Create a File                                                 */
/*-----------------------------------------------------------------------*/

FRESULT f_open (
	FIL *fp,			/* Pointer to the blank file object */
	const char *path,	/* Pointer to the file name */
	BYTE mode			/* Access mode and file open mode flags */
)
{
	FRESULT res;
	BYTE *dir;
	DIR dirobj;
	char fn[8+3+1];
	FATFS *fs = FatFs;


	fp->fs = NULL;
#if !_FS_READONLY
	mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
	res = auto_mount(&path, (BYTE)(mode & (FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)));
#else
	mode &= FA_READ;
	res = auto_mount(&path, 0);
#endif
	if (res != FR_OK) return res;

	/* Trace the file path */
	res = trace_path(&dirobj, fn, path, &dir);	/* Trace the file path */

#if !_FS_READONLY
	/* Create or Open a File */
	if (mode & (FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)) {
		CLUST rs;
		DWORD dw;
		if (res != FR_OK) {		/* No file, create new */
			if (res != FR_NO_FILE) return res;
			res = reserve_direntry(&dirobj, &dir);
			if (res != FR_OK) return res;
			memset(dir, 0, 32);		/* Initialize the new entry */
			memcpy(&dir[DIR_Name], fn, 8+3);
			dir[DIR_NTres] = fn[11];
			mode |= FA_CREATE_ALWAYS;
		} else {				/* Any object is already existing */
			if (mode & FA_CREATE_NEW)			/* Cannot create new */
				return FR_EXIST;
			if (dir == NULL || (dir[DIR_Attr] & (AM_RDO|AM_DIR)))	/* Cannot overwrite (R/O or DIR) */
				return FR_DENIED;
			if (mode & FA_CREATE_ALWAYS) {		/* Resize it to zero */
#if _FAT32
				rs = ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) | LD_WORD(&dir[DIR_FstClusLO]);
				ST_WORD(&dir[DIR_FstClusHI], 0);
#else
				rs = LD_WORD(&dir[DIR_FstClusLO]);
#endif
				ST_WORD(&dir[DIR_FstClusLO], 0);	/* cluster = 0 */
				ST_DWORD(&dir[DIR_FileSize], 0);	/* size = 0 */
				fs->winflag = 1;
				dw = fs->winsect;				/* Remove the cluster chain */
				if (!remove_chain(rs) || !move_window(dw))
					return FR_RW_ERROR;
				fs->last_clust = rs - 1;		/* Reuse the cluster hole */
			}
		}
		if (mode & FA_CREATE_ALWAYS) {
			dir[DIR_Attr] = AM_ARC;		/* New attribute */
			dw = get_fattime();
			ST_DWORD(&dir[DIR_WrtTime], dw);	/* Updated time */
			ST_DWORD(&dir[DIR_CrtTime], dw);	/* Created time */
			fs->winflag = 1;
		}
	}
	/* Open a File */
	else {
#endif /* !_FS_READONLY */
		if (res != FR_OK) return res;		/* Trace failed */
		if (dir == NULL || (dir[DIR_Attr] & AM_DIR))	/* It is a directory */
			return FR_NO_FILE;
#if !_FS_READONLY
		if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */
			return FR_DENIED;
	}

	fp->dir_sect = fs->winsect;			/* Pointer to the directory entry */
	fp->dir_ptr = dir;
#endif
	fp->flag = mode;							/* File access mode */
	fp->org_clust =								/* File start cluster */
#if _FAT32
		((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
#endif
		LD_WORD(&dir[DIR_FstClusLO]);
	fp->fsize = LD_DWORD(&dir[DIR_FileSize]);	/* File size */
	fp->fptr = 0;								/* File ptr */
	fp->sect_clust = 1;							/* Sector counter */
	fp->fs = fs; fp->id = fs->id;				/* Owner file system object of the file */

	return FR_OK;
}




/*-----------------------------------------------------------------------*/
/* Read File                                                             */
/*-----------------------------------------------------------------------*/

FRESULT f_read (
	FIL *fp, 		/* Pointer to the file object */
	void *buff,		/* Pointer to data buffer */
	WORD btr,		/* Number of bytes to read */
	WORD *br		/* Pointer to number of bytes read */
)
{
	DWORD sect, remain;
	WORD rcnt;
	CLUST clust;
	BYTE cc, *rbuff = buff;
	FRESULT res;
	FATFS *fs = fp->fs;


	*br = 0;
	res = validate(fs, fp->id);						/* Check validity of the object */
	if (res) return res;
	if (fp->flag & FA__ERROR) return FR_RW_ERROR;	/* Check error flag */
	if (!(fp->flag & FA_READ)) return FR_DENIED;	/* Check access mode */
	remain = fp->fsize - fp->fptr;
	if (btr > remain) btr = (WORD)remain;			/* Truncate read count by number of bytes left */

	for ( ;  btr;									/* Repeat until all data transferred */
		rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
		if ((fp->fptr % 512) == 0) {				/* On the sector boundary */
			if (--fp->sect_clust) {					/* Decrement left sector counter */
				sect = fp->curr_sect + 1;			/* Get current sector */
			} else {								/* On the cluster boundary, get next cluster */
				clust = (fp->fptr == 0) ?
					fp->org_clust : get_cluster(fp->curr_clust);
				if (clust < 2 || clust >= fs->max_clust)
					goto fr_error;
				fp->curr_clust = clust;				/* Current cluster */
				sect = clust2sect(clust);			/* Get current sector */
				fp->sect_clust = fs->sects_clust;	/* Re-initialize the left sector counter */
			}
			fp->curr_sect = sect;					/* Update current sector */
			cc = btr / 512;							/* When left bytes >= 512, */
			if (cc) {								/* Read maximum contiguous sectors directly */
				if (cc > fp->sect_clust) cc = fp->sect_clust;
				if (disk_read(0, rbuff, sect, cc) != RES_OK)
					goto fr_error;
				fp->sect_clust -= cc - 1;
				fp->curr_sect += cc - 1;
				rcnt = cc * 512; continue;
			}
		}
		if (!move_window(fp->curr_sect)) goto fr_error;	/* Move sector window */
		rcnt = 512 - (WORD)(fp->fptr % 512);			/* Copy fractional bytes from sector window */
		if (rcnt > btr) rcnt = btr;
		memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
	}

	return FR_OK;

fr_error:	/* Abort this function due to an unrecoverable error */
	fp->flag |= FA__ERROR;
	return FR_RW_ERROR;
}




#if !_FS_READONLY
/*-----------------------------------------------------------------------*/
/* Write File                                                            */
/*-----------------------------------------------------------------------*/

FRESULT f_write (
	FIL *fp,			/* Pointer to the file object */
	const void *buff,	/* Pointer to the data to be written */
	WORD btw,			/* Number of bytes to write */
	WORD *bw			/* Pointer to number of bytes written */
)
{
	DWORD sect;
	WORD wcnt;
	CLUST clust;
	BYTE cc;
	FRESULT res;
	const BYTE *wbuff = buff;
	FATFS *fs = fp->fs;


	*bw = 0;
	res = validate(fs, fp->id);						/* Check validity of the object */
	if (res) return res;
	if (fp->flag & FA__ERROR) return FR_RW_ERROR;	/* Check error flag */
	if (!(fp->flag & FA_WRITE)) return FR_DENIED;	/* Check access mode */
	if (fp->fsize + btw < fp->fsize) return FR_OK;	/* File size cannot reach 4GB */

	for ( ;  btw;									/* Repeat until all data transferred */
		wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
		if ((fp->fptr % 512) == 0) {				/* On the sector boundary */
			if (--(fp->sect_clust)) {				/* Decrement left sector counter */
				sect = fp->curr_sect + 1;			/* Get current sector */
			} else {								/* On the cluster boundary, get next cluster */
				if (fp->fptr == 0) {				/* Is top of the file */
					clust = fp->org_clust;
					if (clust == 0)					/* No cluster is created yet */
						fp->org_clust = clust = create_chain(0);	/* Create a new cluster chain */
				} else {							/* Middle or end of file */
					clust = create_chain(fp->curr_clust);			/* Trace or streach cluster chain */
				}
				if (clust == 0) break;				/* Disk full */
				if (clust == 1 || clust >= fs->max_clust) goto fw_error;
				fp->curr_clust = clust;				/* Current cluster */
				sect = clust2sect(clust);			/* Get current sector */
				fp->sect_clust = fs->sects_clust;	/* Re-initialize the left sector counter */
			}
			fp->curr_sect = sect;					/* Update current sector */
			cc = btw / 512;							/* When left bytes >= 512, */
			if (cc) {								/* Write maximum contiguous sectors directly */
				if (cc > fp->sect_clust) cc = fp->sect_clust;
				if (disk_write(0, wbuff, sect, cc) != RES_OK)
					goto fw_error;
				fp->sect_clust -= cc - 1;
				fp->curr_sect += cc - 1;
				wcnt = cc * 512; continue;
			}
			if (fp->fptr >= fp->fsize) {			/* Flush R/W window if needed */
				if (!move_window(0)) goto fw_error;
				fs->winsect = fp->curr_sect;
			}
		}
		if (!move_window(fp->curr_sect))			/* Move sector window */
			goto fw_error;
		wcnt = 512 - (WORD)(fp->fptr % 512);			/* Copy fractional bytes bytes to sector window */
		if (wcnt > btw) wcnt = btw;
		memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
		fs->winflag = 1;
	}

	if (fp->fptr > fp->fsize) fp->fsize = fp->fptr;	/* Update file size if needed */
	fp->flag |= FA__WRITTEN;						/* Set file changed flag */
	return FR_OK;

fw_error:	/* Abort this function due to an unrecoverable error */
	fp->flag |= FA__ERROR;
	return FR_RW_ERROR;
}




/*-----------------------------------------------------------------------*/
/* Synchronize between File and Disk                                     */
/*-----------------------------------------------------------------------*/

FRESULT f_sync (
	FIL *fp		/* Pointer to the file object */
)
{
	DWORD tim;
	BYTE *dir;
	FRESULT res;
	FATFS *fs = fp->fs;


	res = validate(fs, fp->id);				/* Check validity of the object */
	if (res == FR_OK) {
		if (fp->flag & FA__WRITTEN) {		/* Has the file been written? */
			/* Update the directory entry */
			if (!move_window(fp->dir_sect))
				return FR_RW_ERROR;
			dir = fp->dir_ptr;
			dir[DIR_Attr] |= AM_ARC;						/* Set archive bit */
			ST_DWORD(&dir[DIR_FileSize], fp->fsize);		/* Update file size */
			ST_WORD(&dir[DIR_FstClusLO], fp->org_clust);	/* Update start cluster */
#if _FAT32
			ST_WORD(&dir[DIR_FstClusHI], fp->org_clust >> 16);
#endif
			tim = get_fattime();					/* Updated time */
			ST_DWORD(&dir[DIR_WrtTime], tim);
			fp->flag &= ~FA__WRITTEN;
			res = sync();
		}
	}
	return res;
}

#endif /* !_FS_READONLY */




/*-----------------------------------------------------------------------*/
/* Close File                                                            */
/*-----------------------------------------------------------------------*/

FRESULT f_close (
	FIL *fp		/* Pointer to the file object to be closed */
)
{
	FRESULT res;


#if !_FS_READONLY
	res = f_sync(fp);
#else
	res = validate(fp->fs, fp->id);
#endif
	if (res == FR_OK)
		fp->fs = NULL;

	return res;
}




#if _FS_MINIMIZE <= 2
/*-----------------------------------------------------------------------*/
/* Seek File Pointer                                                     */
/*-----------------------------------------------------------------------*/

FRESULT f_lseek (
	FIL *fp,		/* Pointer to the file object */
	DWORD ofs		/* File pointer from top of file */
)
{
	CLUST clust;
	DWORD csize;
	BYTE csect;
	FRESULT res;
	FATFS *fs = fp->fs;


	res = validate(fs, fp->id);			/* Check validity of the object */
	if (res) return res;

	if (fp->flag & FA__ERROR) return FR_RW_ERROR;
#if !_FS_READONLY
	if (ofs > fp->fsize && !(fp->flag & FA_WRITE))
#else
	if (ofs > fp->fsize)
#endif
		ofs = fp->fsize;
	fp->fptr = 0; fp->sect_clust = 1;		/* Set file R/W pointer to top of the file */

	/* Move file R/W pointer if needed */
	if (ofs) {
		clust = fp->org_clust;	/* Get start cluster */
#if !_FS_READONLY
		if (!clust) {			/* If the file does not have a cluster chain, create new cluster chain */
			clust = create_chain(0);
			if (clust == 1) goto fk_error;
			fp->org_clust = clust;
		}
#endif
		if (clust) {			/* If the file has a cluster chain, it can be followed */
			csize = (DWORD)fs->sects_clust * 512;		/* Cluster size in unit of byte */
			for (;;) {									/* Loop to skip leading clusters */
				fp->curr_clust = clust;					/* Update current cluster */
				if (ofs <= csize) break;
#if !_FS_READONLY
				if (fp->flag & FA_WRITE)				/* Check if in write mode or not */
					clust = create_chain(clust);		/* Force streached if in write mode */
				else
#endif
					clust = get_cluster(clust);			/* Only follow cluster chain if not in write mode */
				if (clust == 0) {						/* Stop if could not follow the cluster chain */
					ofs = csize; break;
				}
				if (clust == 1 || clust >= fs->max_clust) goto fk_error;
				fp->fptr += csize;						/* Update R/W pointer */
				ofs -= csize;
			}
			csect = (BYTE)((ofs - 1) / 512);			/* Sector offset in the cluster */
			fp->curr_sect = clust2sect(clust) + csect;	/* Current sector */
			fp->sect_clust = fs->sects_clust - csect;	/* Left sector counter in the cluster */
			fp->fptr += ofs;							/* Update file R/W pointer */
		}
	}
#if !_FS_READONLY
	if ((fp->flag & FA_WRITE) && fp->fptr > fp->fsize) {	/* Set updated flag if in write mode */
		fp->fsize = fp->fptr;
		fp->flag |= FA__WRITTEN;
	}
#endif

	return FR_OK;

fk_error:	/* Abort this function due to an unrecoverable error */
	fp->flag |= FA__ERROR;
	return FR_RW_ERROR;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产a级| 国产亚洲人成网站| 亚洲电影在线播放| 欧美理论电影在线| 久久精品二区亚洲w码| 久久久午夜精品| 不卡影院免费观看| 亚洲国产日韩综合久久精品| 欧美一区二区三区在线| 国产麻豆精品视频| 亚洲激情自拍偷拍| 91精品国产色综合久久不卡蜜臀| 捆绑调教美女网站视频一区| 国产天堂亚洲国产碰碰| 色av一区二区| 日韩精品91亚洲二区在线观看| 精品国产乱码久久久久久1区2区| 懂色av一区二区三区蜜臀| 一区二区视频在线| 欧美电影免费观看高清完整版在 | 欧美综合亚洲图片综合区| 色综合天天综合在线视频| 国产精品久久久久久久久免费樱桃 | 国产丝袜欧美中文另类| 91蝌蚪porny成人天涯| 国产v日产∨综合v精品视频| 久久国产精品第一页| 日韩在线卡一卡二| 亚洲国产精品欧美一二99| 亚洲精品欧美二区三区中文字幕| 欧美韩国日本综合| 日本一区二区不卡视频| 国产欧美一区二区三区网站 | 国产免费观看久久| 国产丝袜欧美中文另类| 国产欧美日韩视频一区二区| 国产日韩欧美精品一区| 国产欧美视频在线观看| 国产欧美一区二区精品性色 | 欧美挠脚心视频网站| 欧美日韩亚洲丝袜制服| 欧美伦理视频网站| 91精品国产手机| 精品日韩一区二区三区| 精品国产三级a在线观看| 亚洲精品在线网站| 久久免费国产精品| 欧美极品少妇xxxxⅹ高跟鞋| 日本一区二区综合亚洲| 日韩美女精品在线| 亚洲成av人在线观看| 日本欧美大码aⅴ在线播放| 久久草av在线| 国产91精品露脸国语对白| 99精品欧美一区二区三区小说| 在线观看欧美黄色| 欧美福利一区二区| 久久欧美中文字幕| 亚洲人成小说网站色在线| 亚洲成a人v欧美综合天堂| 久久不见久久见免费视频7| 成人性视频免费网站| 91黄色小视频| 欧美大片在线观看一区二区| 中文字幕不卡在线观看| 一个色在线综合| 九色porny丨国产精品| 国产91丝袜在线播放0| 在线观看亚洲精品| 日韩你懂的在线观看| 国产精品嫩草影院av蜜臀| 亚洲国产成人av网| 国产成人精品三级麻豆| 欧美午夜宅男影院| 久久久久久日产精品| 亚洲一区二区影院| 国产盗摄一区二区三区| 精品视频1区2区| 国产日韩欧美制服另类| 五月天丁香久久| 成人毛片在线观看| 在线不卡中文字幕播放| 国产精品视频线看| 免费在线观看视频一区| 91在线观看高清| 久久一日本道色综合| 午夜久久久久久久久久一区二区| 国产成人免费xxxxxxxx| 欧美久久高跟鞋激| 亚洲四区在线观看| 国产一区二区日韩精品| 91精品在线免费观看| 亚洲女人小视频在线观看| 激情国产一区二区 | 久久精品亚洲精品国产欧美 | 一区二区久久久久久| 国产成人丝袜美腿| 欧美日韩国产高清一区二区 | 亚洲韩国一区二区三区| 成人禁用看黄a在线| 精品国产乱码久久| 亚洲r级在线视频| 91免费看`日韩一区二区| 久久婷婷色综合| 日本成人在线电影网| 色哟哟国产精品| 中文字幕久久午夜不卡| 国产综合色在线| 日韩欧美一二三区| 五月激情综合婷婷| 欧美视频一区二区在线观看| 亚洲日本乱码在线观看| 成人免费视频播放| 久久久精品综合| 国产在线精品免费| 日韩欧美国产电影| 美女网站在线免费欧美精品| 欧美日韩你懂的| 一区二区三区毛片| 色狠狠色噜噜噜综合网| 最近日韩中文字幕| 99精品视频在线观看| 国产精品视频观看| 成人免费看黄yyy456| 久热成人在线视频| 欧美日韩高清在线| 亚洲成人资源在线| 欧美无砖专区一中文字| 亚洲精品videosex极品| 色偷偷88欧美精品久久久| 亚洲男同1069视频| 日本久久一区二区| 一区二区三区精品| 欧美性生活大片视频| 亚洲一区二区视频在线观看| 欧美午夜影院一区| 日韩国产高清影视| 欧美xxx久久| 国产一区二区在线视频| 国产日产精品1区| 国产福利91精品| 亚洲欧洲精品一区二区精品久久久| av不卡免费电影| 亚洲自拍与偷拍| 欧美老女人第四色| 久久se这里有精品| 国产色产综合产在线视频| 成人午夜电影小说| 亚洲裸体xxx| 欧美美女网站色| 韩国女主播成人在线| 国产精品污www在线观看| 色综合网色综合| 日韩va亚洲va欧美va久久| 日韩女优毛片在线| 丁香婷婷深情五月亚洲| 亚洲免费在线视频| 日韩写真欧美这视频| 国产乱子伦视频一区二区三区| 国产精品入口麻豆九色| 欧美性感一区二区三区| 久久99国产精品免费| 中文字幕不卡的av| 欧美三级视频在线播放| 狠狠色丁香久久婷婷综合_中| 国产精品福利一区二区三区| 欧美三片在线视频观看| 精品夜夜嗨av一区二区三区| 中文字幕在线播放不卡一区| 欧美日韩国产一区二区三区地区| 看电视剧不卡顿的网站| 亚洲欧洲成人精品av97| 欧美伦理影视网| 成人毛片在线观看| 日韩影院精彩在线| 中文字幕一区在线观看视频| 欧美一区二区三区电影| eeuss影院一区二区三区| 日韩精品亚洲专区| 国产精品成人免费 | 亚洲乱码中文字幕| 精品国产伦一区二区三区观看方式 | 成人白浆超碰人人人人| 午夜精品久久久久久久蜜桃app| 久久亚洲精华国产精华液| 91国内精品野花午夜精品| 久久99热99| 亚洲韩国精品一区| 国产精品视频一二三区| 日韩欧美一区二区三区在线| 91久久国产最好的精华液| 国产不卡视频一区二区三区| 日韩电影在线免费| 亚洲综合成人在线| 国产精品网曝门| 337p日本欧洲亚洲大胆精品| 欧美日韩精品二区第二页| 99久久精品国产一区二区三区| 精品中文字幕一区二区小辣椒| 亚洲一区二区三区四区五区中文|