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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main__.c

?? this source is for sd mmc read write in fat file system for atmega64
?? C
?? 第 1 頁 / 共 5 頁
字號:

/*-----------------------------------------------------------------------*/
/* 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 != FR_OK) 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;
}




#if _FS_MINIMIZE <= 1
/*-----------------------------------------------------------------------*/
/* Open a directroy                                                      */
/*-----------------------------------------------------------------------*/

FRESULT f_opendir (
	DIR *dirobj,		/* Pointer to directory object to create */
	const char *path	/* Pointer to the directory path */
)
{
	BYTE *dir;
	char fn[8+3+1];
	FRESULT res;
	FATFS *fs = FatFs;


	res = auto_mount(&path, 0);
	if (res != FR_OK) return res;

	res = trace_path(dirobj, fn, path, &dir);	/* Trace the directory path */
	if (res == FR_OK) {							/* Trace completed */
		if (dir != NULL) {						/* It is not the root dir */
			if (dir[DIR_Attr] & AM_DIR) {		/* The entry is a directory */
	 			dirobj->clust =
#if _FAT32
					((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
#endif
					LD_WORD(&dir[DIR_FstClusLO]);
				dirobj->sect = clust2sect(dirobj->clust);
				dirobj->index = 2;
			} else {						/* The entry is not a directory */
				res = FR_NO_FILE;
			}
		}
		dirobj->id = fs->id;
	}
	return res;
}




/*-----------------------------------------------------------------------*/
/* Read Directory Entry in Sequense                                      */
/*-----------------------------------------------------------------------*/

FRESULT f_readdir (
	DIR *dirobj,		/* Pointer to the directory object */
	FILINFO *finfo		/* Pointer to file information to return */
)
{
	BYTE *dir, c;
	FRESULT res;
	FATFS *fs = dirobj->fs;


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

	finfo->fname[0] = 0;
	while (dirobj->sect) {
		if (!move_window(dirobj->sect))
			return FR_RW_ERROR;
		dir = &fs->win[(dirobj->index & 15) * 32];		/* pointer to the directory entry */
		c = dir[DIR_Name];
		if (c == 0) break;								/* Has it reached to end of dir? */
		if (c != 0xE5 && !(dir[DIR_Attr] & AM_VOL))		/* Is it a valid entry? */
			get_fileinfo(finfo, dir);
		if (!next_dir_entry(dirobj)) dirobj->sect = 0;	/* Next entry */
		if (finfo->fname[0]) break;						/* Found valid entry */
	}

	return FR_OK;
}




#if _FS_MINIMIZE == 0
/*-----------------------------------------------------------------------*/
/* Get File Status                                                       */
/*-----------------------------------------------------------------------*/

FRESULT f_stat (
	const char *path,	/* Pointer to the file path */
	FILINFO *finfo		/* Pointer to file information to return */
)
{
	BYTE *dir;
	char fn[8+3+1];
	FRESULT res;
	DIR dirobj;


	res = auto_mount(&path, 0);
	if (res != FR_OK) return res;

	res = trace_path(&dirobj, fn, path, &dir);	/* Trace the file path */
	if (res == FR_OK) {							/* Trace completed */
		if (dir)	/* Found an object */
			get_fileinfo(finfo, dir);
		else		/* It is root dir */
			res = FR_INVALID_NAME;
	}

	return res;
}




#if !_FS_READONLY
/*-----------------------------------------------------------------------*/
/* Get Number of Free Clusters                                           */
/*-----------------------------------------------------------------------*/

FRESULT f_getfree (
	const char *drv,	/* Logical drive number */
	DWORD *nclust,		/* Pointer to the double word to return number of free clusters */
	FATFS **fatfs		/* Pointer to pointer to the file system object to return */
)
{
	DWORD n, sect;
	CLUST clust;
	BYTE fat, f, *p;
	FRESULT res;
	FATFS *fs;


	/* Get drive number */
	res = auto_mount(&drv, 0);
	if (res != FR_OK) return res;
	*fatfs = fs = FatFs;

	/* If number of free cluster is valid, return it without cluster scan. */
	if (fs->free_clust <= fs->max_clust - 2) {
		*nclust = fs->free_clust;
		return FR_OK;
	}

	/* Count number of free clusters */
	fat = fs->fs_type;
	n = 0;
	if (fat == FS_FAT12) {
		clust = 2;
		do {
			if ((WORD)get_cluster(clust) == 0) n++;
		} while (++clust < fs->max_clust);
	} else {
		clust = fs->max_clust;
		sect = fs->fatbase;
		f = 0; p = 0;
		do {
			if (!f) {
				if (!move_window(sect++)) return FR_RW_ERROR;
				p = fs->win;
			}
			if (!_FAT32 || fat == FS_FAT16) {
				if (LD_WORD(p) == 0) n++;
				p += 2; f += 1;
			} else {
				if (LD_DWORD(p) == 0) n++;
				p += 4; f += 2;
			}
		} while (--clust);
	}
	fs->free_clust = n;
#if _USE_FSINFO
	if (fat == FS_FAT32) fs->fsi_flag = 1;
#endif

	*nclust = n;
	return FR_OK;
}




/*-----------------------------------------------------------------------*/
/* Delete a File or a Directory                                          */
/*-----------------------------------------------------------------------*/

FRESULT f_unlink (
	const char *path			/* Pointer to the file or directory path */
)
{
	BYTE *dir, *sdir;
	DWORD dsect;
	char fn[8+3+1];
	CLUST dclust;
	FRESULT res;
	DIR dirobj;
	FATFS *fs = FatFs;


	res = auto_mount(&path, 1);
	if (res != FR_OK) return res;

	res = trace_path(&dirobj, fn, path, &dir);	/* Trace the file path */
	if (res != FR_OK) return res;				/* Trace failed */
	if (dir == NULL) return FR_INVALID_NAME;	/* It is the root directory */
	if (dir[DIR_Attr] & AM_RDO) return FR_DENIED;	/* It is a R/O object */
	dsect = fs->winsect;
	dclust =
#if _FAT32
		((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
#endif
		LD_WORD(&dir[DIR_FstClusLO]);
	if (dir[DIR_Attr] & AM_DIR) {				/* It is a sub-directory */
		dirobj.clust = dclust;					/* Check if the sub-dir is empty or not */
		dirobj.sect = clust2sect(dclust);
		dirobj.index = 2;
		do {
			if (!move_window(dirobj.sect)) return FR_RW_ERROR;
			sdir = &fs->win[(dirobj.index & 15) * 32];
			if (sdir[DIR_Name] == 0) break;
			if (sdir[DIR_Name] != 0xE5 && !(sdir[DIR_Attr] & AM_VOL))
				return FR_DENIED;	/* The directory is not empty */
		} while (next_dir_entry(&dirobj));
	}

	if (!move_window(dsect)) return FR_RW_ERROR;	/* Mark the directory entry 'deleted' */
	dir[DIR_Name] = 0xE5;
	fs->winflag = 1;
	if (!remove_chain(dclust)) return FR_RW_ERROR;	/* Remove the cluster chain */

	return sync();
}




/*-----------------------------------------------------------------------*/
/* Create a Directory                                                    */
/*-----------------------------------------------------------------------*/

FRESULT f_mkdir (
	const char *path		/* Pointer to the directory path */
)
{
	BYTE *dir, *fw, n;
	char fn[8+3+1];
	DWORD sect, dsect, tim;
	CLUST dclust, pclust;
	FRESULT res;
	DIR dirobj;
	FATFS *fs = FatFs;


	res = auto_mount(&path, 1);
	if (res != FR_OK) return res;

	res = trace_path(&dirobj, fn, path, &dir);	/* Trace the file path */
	if (res == FR_OK) return FR_EXIST;			/* Any file or directory is already existing */
	if (res != FR_NO_FILE) return res;

	res = reserve_direntry(&dirobj, &dir); 		/* Reserve a directory entry */
	if (res != FR_OK) return res;
	sect = fs->winsect;
	dclust = create_chain(0);					/* Allocate a cluster for new directory table */
	if (dclust == 1) return FR_RW_ERROR;
	dsect = clust2sect(dclust);
	if (!dsect) return FR_DENIED;
	if (!move_window(dsect)) return FR_RW_ERROR;

	fw = fs->win;
	memset(fw, 0, 512);							/* Clear the directory table */
	for (n = 1; n < fs->sects_clust; n++) {
		if (disk_write(0, fw, ++dsect, 1) != RES_OK)
			return FR_RW_ERROR;
	}

	memset(&fw[DIR_Name], ' ', 8+3);			/* Create "." entry */
	fw[DIR_Name] = '.';
	fw[DIR_Attr] = AM_DIR;
	tim = get_fattime();
	ST_DWORD(&fw[DIR_WrtTime], tim);
	memcpy(&fw[32], &fw[0], 32); fw[33] = '.';	/* Create ".." entry */
	pclust = dirobj.sclust;
#if _FAT32
	ST_WORD(&fw[   DIR_FstClusHI], dclust >> 16);
	if (fs->fs_type == FS_FAT32 && pclust == fs->dirbase) pclust = 0;
	ST_WORD(&fw[32+DIR_FstClusHI], pclust >> 16);
#endif
	ST_WORD(&fw[   DIR_FstClusLO], dclust);
	ST_WORD(&fw[32+DIR_FstClusLO], pclust);
	fs->winflag = 1;

	if (!move_window(sect)) return FR_RW_ERROR;
	memset(&dir[0], 0, 32);						/* Clean-up the new entry */
	memcpy(&dir[DIR_Name], fn, 8+3);			/* Name */
	dir[DIR_NTres] = fn[11];
	dir[DIR_Attr] = AM_DIR;						/* Attribute */
	ST_DWORD(&dir[DIR_WrtTime], tim);			/* Crated time */
	ST_WORD(&dir[DIR_FstClusLO], dclust);		/* Table start cluster */
#if _FAT32
	ST_WORD(&dir[DIR_FstClusHI], dclust >> 16);
#endif

	return sync();
}




/*-----------------------------------------------------------------------*/
/* Change File Attribute                                                 */
/*--------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产日韩a欧美在线观看| 国产精品久久久久婷婷| 欧美三区在线视频| 色诱视频网站一区| 欧美一区二区视频观看视频| 精品少妇一区二区三区| 中文字幕亚洲欧美在线不卡| 水野朝阳av一区二区三区| 久久er精品视频| 成人美女在线观看| 欧美日韩一区小说| 精品国产成人系列| 亚洲色图色小说| 经典三级视频一区| 日本韩国精品在线| 久久精品免视看| 亚洲成人资源网| 狠狠色丁香婷婷综合久久片| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 亚洲综合色噜噜狠狠| 日韩成人av影视| 亚洲六月丁香色婷婷综合久久| 亚洲成a人在线观看| 欧美一区二区三区免费| 国产乱码精品一区二区三| 欧美日韩国产a| 一区二区三区中文字幕精品精品| 91麻豆国产精品久久| 亚洲高清视频的网址| 成人高清视频免费观看| 91精品国产入口| 亚洲精品videosex极品| 久久精品99国产精品日本| 欧美激情综合五月色丁香小说| 色综合天天综合狠狠| 精品久久久久久久久久久院品网 | 在线观看区一区二| 国产精品狼人久久影院观看方式| 欧美视频精品在线观看| 亚洲制服欧美中文字幕中文字幕| 日韩你懂的在线观看| 三级不卡在线观看| 国产精品久久久久久久第一福利| 欧美精品99久久久**| 视频一区二区国产| 国产精品女上位| 成人黄色小视频| 另类综合日韩欧美亚洲| 亚洲精品视频一区| 国产欧美一区二区精品仙草咪 | 国产日韩欧美不卡| 欧美精品 日韩| 国产精品理论片| 久久综合一区二区| 麻豆成人91精品二区三区| 91精品国产品国语在线不卡| 不卡一卡二卡三乱码免费网站| 日韩不卡一区二区三区| 亚洲电影一区二区三区| 亚洲欧美综合在线精品| 国产日韩亚洲欧美综合| 欧美一级二级三级蜜桃| 狠狠色狠狠色综合| 天天影视涩香欲综合网| 精品不卡在线视频| 91精品国产麻豆| 欧美日韩国产成人在线免费| 欧美性猛交一区二区三区精品 | 精久久久久久久久久久| 婷婷六月综合亚洲| 亚欧色一区w666天堂| 一区二区三区免费在线观看| 亚洲欧美激情小说另类| 欧美三级日本三级少妇99| 97久久精品人人爽人人爽蜜臀| 一区二区三区在线视频免费观看| 亚洲国产高清在线| 久久精品水蜜桃av综合天堂| 精品日韩一区二区| 欧美成人精品1314www| 欧美tk—视频vk| 日韩一本二本av| 日韩欧美电影在线| 欧美电影免费观看完整版| 日韩一级欧美一级| 欧美va在线播放| 精品av综合导航| 久久精品在线观看| 国产精品视频免费| 国产精品乱人伦中文| 亚洲欧美综合另类在线卡通| 成人欧美一区二区三区视频网页| 国产精品久99| 一区二区三区四区五区视频在线观看 | 岛国av在线一区| 成人激情校园春色| 91网站在线播放| 欧美日韩免费观看一区三区| 欧美一区二区三区婷婷月色| 欧美mv日韩mv| 欧美国产日韩在线观看| 亚洲精品成人在线| 亚洲成人777| 久久爱另类一区二区小说| 国产成人亚洲综合a∨猫咪| 偷拍一区二区三区四区| 激情五月激情综合网| 国产v日产∨综合v精品视频| 美女在线视频一区| 国产成人一区二区精品非洲| 99精品热视频| 777色狠狠一区二区三区| 99re66热这里只有精品3直播 | 国产精品三级av| 亚洲狠狠爱一区二区三区| 麻豆国产欧美一区二区三区| 国产成人在线视频免费播放| 色婷婷精品大在线视频| 日韩美女主播在线视频一区二区三区| 国产欧美日韩综合精品一区二区| 亚洲狠狠丁香婷婷综合久久久| 日本 国产 欧美色综合| 亚洲成av人**亚洲成av**| 激情综合一区二区三区| 日本国产一区二区| 久久午夜电影网| 亚洲国产精品一区二区www在线| 美美哒免费高清在线观看视频一区二区 | 欧美xxxxxxxxx| 亚洲精品国产无天堂网2021| 久久精工是国产品牌吗| 91精品1区2区| 国产午夜精品一区二区三区视频 | 成人美女视频在线观看18| 亚洲欧洲制服丝袜| 久久久九九九九| 制服丝袜亚洲精品中文字幕| 国产日韩欧美电影| 蜜桃视频在线观看一区| 在线观看国产91| 久久精品亚洲乱码伦伦中文| 蜜桃传媒麻豆第一区在线观看| 91麻豆国产福利在线观看| 国产午夜久久久久| 国产69精品一区二区亚洲孕妇| 欧美性三三影院| 亚洲视频在线观看三级| 国产一区二区按摩在线观看| 黄页视频在线91| 69堂精品视频| 午夜精品久久一牛影视| 色婷婷综合视频在线观看| 久久久亚洲精品一区二区三区| 日本不卡一二三| 国产原创一区二区三区| 日韩一级片在线观看| 日韩美一区二区三区| 日韩和欧美一区二区| 欧洲色大大久久| 亚洲欧美韩国综合色| av激情成人网| 欧美视频一区二区三区四区| 国产精品美女视频| 国产·精品毛片| 欧美激情综合在线| 国产很黄免费观看久久| 久久人人爽人人爽| 久久99精品久久久久| 日韩三级视频中文字幕| 免费高清在线视频一区·| 91精品欧美久久久久久动漫| 丝袜美腿成人在线| 欧美一级二级三级蜜桃| 天堂在线亚洲视频| 91精品国产一区二区人妖| 日本伊人色综合网| 日韩视频一区二区三区| 久久av中文字幕片| 久久嫩草精品久久久久| 国产suv精品一区二区883| 国产精品美日韩| 96av麻豆蜜桃一区二区| 伊人婷婷欧美激情| 欧美日韩高清在线播放| 日本91福利区| 久久精品亚洲麻豆av一区二区| 成人毛片在线观看| 亚洲一区二区四区蜜桃| 6080午夜不卡| 国产精品中文字幕日韩精品| 欧美国产成人精品| 色婷婷综合在线| 视频在线在亚洲| 久久人人超碰精品| www..com久久爱| 亚洲午夜激情网页| 精品国产免费一区二区三区香蕉| av毛片久久久久**hd| 欧美一区二区三区男人的天堂| 国产毛片一区二区|