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

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

?? fatfs.c

?? 分享:Dos操作系統的源程序
?? C
?? 第 1 頁 / 共 4 頁
字號:
/****************************************************************/
/*                                                              */
/*                          fatfs.c                             */
/*                           DOS-C                              */
/*                                                              */
/*                 FAT File System I/O Functions                */
/*                                                              */
/*                      Copyright (c) 1995                      */
/*                      Pasquale J. Villani                     */
/*                      All Rights Reserved                     */
/*                                                              */
/* This file is part of DOS-C.                                  */
/*                                                              */
/* DOS-C is free software; you can redistribute it and/or       */
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version.                    */
/*                                                              */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of   */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
/* the GNU General Public License for more details.             */
/*                                                              */
/* You should have received a copy of the GNU General Public    */
/* License along with DOS-C; see the file COPYING.  If not,     */
/* write to the Free Software Foundation, 675 Mass Ave,         */
/* Cambridge, MA 02139, USA.                                    */
/****************************************************************/

#include "../../hdr/portab.h"
#include "globals.h"


#ifdef VERSION_STRINGS
BYTE *RcsId = "$Header:   C:/dos-c/src/fs/fatfs.c_v   1.12   03 Feb 1998 11:28:04   patv  $";
#endif

/* $Log:   C:/dos-c/src/fs/fatfs.c_v  $
 * 
 *    Rev 1.12   03 Feb 1998 11:28:04   patv
 * Fixed lseek bug.
 * 
 *    Rev 1.11   22 Jan 1998  5:38:08   patv
 * Corrected remaining file name and extension copies that did not
 * account for far file nodes due to allocated FILES= spec.
 * 
 *    Rev 1.10   22 Jan 1998  4:09:00   patv
 * Fixed pointer problems affecting SDA
 * 
 *    Rev 1.9   04 Jan 1998 23:14:40   patv
 * Changed Log for strip utility
 * 
 *    Rev 1.8   04 Jan 1998 17:24:14   patv
 * Corrected subdirectory bug
 * 
 *    Rev 1.7   03 Jan 1998  8:36:04   patv
 * Converted data area to SDA format
 * 
 *    Rev 1.6   22 Jan 1997 13:00:30   patv
 * pre-0.92 bug fixes
 * 
 *    Rev 1.5   16 Jan 1997 12:46:24   patv
 * pre-Release 0.92 feature additions
 * 
 *    Rev 1.4   29 May 1996 21:15:16   patv
 * bug fixes for v0.91a
 * 
 *    Rev 1.3   19 Feb 1996  3:20:10   patv
 * Added NLS, int2f and config.sys processing
 * 
 *    Rev 1.2   01 Sep 1995 17:48:40   patv
 * First GPL release.
 * 
 *    Rev 1.1   30 Jul 1995 20:50:24   patv
 * Eliminated version strings in ipl
 * 
 *    Rev 1.0   02 Jul 1995  8:04:46   patv
 * Initial revision.
 */
/* $EndLog$ */


/*                                                                      */
/*      function prototypes                                             */
/*                                                                      */
struct f_node FAR *xlt_fd(COUNT);
COUNT xlt_fnp(struct f_node FAR *);
struct f_node FAR *split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *);
BOOL find_fname(struct f_node FAR *, BYTE *, BYTE *);
date dos_getdate(VOID);
time dos_gettime(VOID);
BOOL find_free(struct f_node FAR *);
UWORD find_fat_free(struct f_node FAR *);
VOID wipe_out(struct f_node FAR *);
BOOL last_link(struct f_node FAR *);
BOOL extend(struct f_node FAR *);
COUNT extend_dir(struct f_node FAR *);
BOOL first_fat(struct f_node FAR *);
COUNT map_cluster(struct f_node FAR *, COUNT);


/************************************************************************/
/*                                                                      */
/*      Internal file handlers - open, create, read, write, close, etc. */
/*                                                                      */
/************************************************************************/

/* Open a file given the path. Flags is 0 for read, 1 for write and 2   */
/* for update.                                                          */
/* Returns an integer file desriptor or a negative error code           */

COUNT 
dos_open (BYTE FAR *path, COUNT flag)
{
	REG struct f_node FAR *fnp;
	COUNT i;
	BYTE FAR *fnamep;

	/* First test the flag to see if the user has passed a valid    */
	/* file mode...                                                 */
	if(flag < 0 || flag > 2)
		return DE_INVLDACC;

	/* first split the passed dir into comopnents (i.e. - path to   */
	/* new directory and name of new directory.                     */
	if((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL)
	{
		dir_close(fnp);
		return DE_PATHNOTFND;
	}

	/* Look for the file. If we can't find it, just return a not    */
	/* found error.                                                 */
	if(!find_fname(fnp, szFileName, szFileExt))
	{
		dir_close(fnp);
		return DE_FILENOTFND;
	}

	/* Set the fnode to the desired mode                            */
	fnp -> f_mode = flag;

	/* Initialize the rest of the fnode.                            */
	fnp -> f_offset = 0l;
	fnp -> f_highwater = fnp -> f_dir.dir_size;

	fnp -> f_back = LONG_LAST_CLUSTER;
	fnp -> f_cluster = fnp -> f_dir.dir_start;

	fnp -> f_flags.f_dmod = FALSE;
	fnp -> f_flags.f_dnew = FALSE;
	fnp -> f_flags.f_ddir = FALSE;

	return xlt_fnp(fnp);
}


#ifndef IPL
BOOL fcmp(s1, s2, n)
BYTE FAR *s1, FAR *s2;
COUNT n;
{
	while(n--)
		if(*s1++ != *s2++)
			return FALSE;
	return TRUE;
}


BOOL fcmp_wild(s1, s2, n)
BYTE FAR *s1, FAR *s2;
COUNT n;
{
	while(n--)
	{
		if(*s1 == '?')
		{
			++s1, ++s2;
			continue;
		}
		if(*s1++ != *s2++)
			return FALSE;
	}
	return TRUE;
}
#endif


COUNT 
dos_close (COUNT fd)
{
	struct f_node FAR *fnp;

	/* Translate the fd into a useful pointer                       */
	fnp = xlt_fd(fd);

	/* If the fd was invalid because it was out of range or the     */
	/* requested file was not open, tell the caller and exit        */
	/* note: an invalid fd is indicated by a 0 return               */
	if(fnp == (struct f_node FAR *)0 || fnp -> f_count <= 0)
		return DE_INVLDHNDL;
	if(fnp -> f_mode != RDONLY)
	{
		fnp -> f_dir.dir_size = fnp -> f_highwater;
		fnp -> f_flags.f_dmod = TRUE;
	}
	fnp -> f_flags.f_ddir = TRUE;
	
	dir_close(fnp);
	return SUCCESS;
}


/*                                                                      */
/* split a path into it's component directory and file name             */
/*                                                                      */
static struct f_node FAR *
split_path (BYTE FAR *path, BYTE *dname, BYTE *fname, BYTE *fext)
{
	REG struct f_node FAR *fnp;
	COUNT nDrive;
	struct dpb *dpbp;
	

	/* Start off by parsing out the components.			*/
	ParseDosName(adjust_far(path), &nDrive, &dname[2], fname, fext);
	if(nDrive < 0)
		nDrive = default_drive;
	dname[0] = 'A' + nDrive;
	dname[1] = ':';

	/* Add trailing spaces to the file name and extension		*/
	SpacePad(fname, FNAME_SIZE);
	SpacePad(fext, FEXT_SIZE);
	
	/* If the path is null, we to default to the current            */
	/* directory...                                                 */
	if(!dname[2])
	{
		dpbp = &blk_devices[nDrive];
		fsncopy((BYTE FAR *)dpbp -> dpb_path,
		        (BYTE FAR *)&dname[2],
		        PARSE_MAX);
	}

	/* Translate the path into a useful pointer                     */
	fnp = dir_open((BYTE FAR *)dname);

	/* If the fd was invalid because it was out of range or the     */
	/* requested file was not open, tell the caller and exit...     */
	/* note: an invalid fd is indicated by a 0 return               */
	if(fnp == (struct f_node FAR *)0 || fnp -> f_count <= 0)
	{
		dir_close(fnp);
		return (struct f_node FAR *)0;
	}

	/* Convert the name into an absolute name for comparison...     */
	upMem((BYTE FAR *)dname, strlen(dname));
	upMem((BYTE FAR *)fname, FNAME_SIZE);
	upMem((BYTE FAR *)fext, FEXT_SIZE);

	return fnp;
}



static BOOL 
find_fname (struct f_node FAR *fnp, BYTE *fname, BYTE *fext)
{
	BOOL found = FALSE;

	while(dir_read(fnp) == DIRENT_SIZE)
	{
		if(fnp -> f_dir.dir_name[0] != '\0')
		{
			if(fnp -> f_dir.dir_name[0] == DELETED)
				continue;
			if(fcmp((BYTE FAR *)fname, (BYTE FAR *)fnp -> f_dir.dir_name, FNAME_SIZE)
			&& fcmp((BYTE FAR *)fext, (BYTE FAR *)fnp -> f_dir.dir_ext, FEXT_SIZE))
			{
				found = TRUE;
				break;
			}
		}
	}
	return found;
}


#ifndef IPL
COUNT 
dos_creat (BYTE FAR *path, COUNT attrib)
{
	REG struct f_node FAR *fnp;

	/* first split the passed dir into comopnents (i.e. -   */
	/* path to new directory and name of new directory      */
	if((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL)
	{
		dir_close(fnp);
		return DE_PATHNOTFND;
	}

	/* Check that we don't have a duplicate name, so if we  */
	/* find one, truncate it.                               */
	if(find_fname(fnp, szFileName, szFileExt))
	{
		/* The only permissable attribute is archive,   */
		/* check for any other bit set. If it is, give  */
		/* an access error.                             */
		if((fnp -> f_dir.dir_attrib & (D_RDONLY | D_DIR | D_VOLID))
		   || (fnp -> f_dir.dir_attrib & ~D_ARCHIVE & ~attrib))
		{
			dir_close(fnp);
			return DE_ACCESS;
		}

		/* Release the existing files FAT and set the   */
		/* length to zero, effectively truncating the   */
		/* file to zero.                                */
		wipe_out(fnp);

	}
	else
	{
		BOOL is_free;
		REG COUNT idx;
		struct buffer FAR *bp;
		BYTE FAR *p;

		/* Reset the directory by a close followed by   */
		/* an open                                      */
		fnp -> f_flags.f_dmod = FALSE;
		dir_close(fnp);
		fnp = dir_open((BYTE FAR *)szDirName);

		/* Get a free f_node pointer so that we can use */
		/* it in building the new file.                 */
		/* Note that if we're in the root and we don't  */
		/* find an empty slot, we need to abort.        */
		if(!(is_free = find_free(fnp)) && (fnp -> f_flags.f_droot))
		{
			fnp -> f_flags.f_dmod = FALSE;
			dir_close(fnp);
			return DE_TOOMANY;
		}

		/* Otherwise just expand the directory          */
		else if(!is_free && !(fnp -> f_flags.f_droot))
		{
			COUNT ret;

			if((ret = extend_dir(fnp)) != SUCCESS)
				return ret;
		}

		/* put the fnode's name into the directory.             */
		fbcopy((BYTE FAR *)szFileName,
		 (BYTE FAR *)fnp -> f_dir.dir_name, FNAME_SIZE);
		fbcopy((BYTE FAR *)szFileExt,
		 (BYTE FAR *)fnp -> f_dir.dir_ext, FEXT_SIZE);
	}
	/* Set the fnode to the desired mode                    */
	/* Updating the directory entry first.                  */
	fnp -> f_mode = RDWR;

	fnp -> f_dir.dir_size = 0l;
	fnp -> f_dir.dir_start = FREE;
	fnp -> f_dir.dir_attrib = attrib | D_ARCHIVE;
	fnp -> f_dir.dir_time = dos_gettime();
	fnp -> f_dir.dir_date = dos_getdate();

	fnp -> f_flags.f_dmod = TRUE;
	fnp -> f_flags.f_dnew = FALSE;
	fnp -> f_flags.f_ddir = TRUE;
	if(dir_write(fnp) != DIRENT_SIZE)
	{
		release_f_node(fnp);
		return DE_ACCESS;
	}

	/* Now change to file                                   */
	fnp -> f_offset = 0l;
	fnp -> f_highwater = 0l;

	fnp -> f_back = LONG_LAST_CLUSTER;
	fnp -> f_cluster = fnp -> f_dir.dir_start = FREE;
	fnp -> f_flags.f_dmod = TRUE;
	fnp -> f_flags.f_dnew = FALSE;
	fnp -> f_flags.f_ddir = FALSE;

	return xlt_fnp(fnp);
}


COUNT 
dos_delete (BYTE FAR *path)
{
	REG struct f_node FAR *fnp;

	/* first split the passed dir into components (i.e. -	*/
	/* path to new directory and name of new directory	*/
	if((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL)
	{
		dir_close(fnp);
		return DE_PATHNOTFND;
	}

	/* Check that we don't have a duplicate name, so if we  */
	/* find one, it's an error.                             */
	if(find_fname(fnp, szFileName, szFileExt))
	{
		/* The only permissable attribute is archive,   */
		/* check for any other bit set. If it is, give  */
		/* an access error.                             */
		if(fnp -> f_dir.dir_attrib & ~D_ARCHIVE)
		{
			dir_close(fnp);
			return DE_ACCESS;
		}

		/* Ok, so we can delete. Start out by           */
		/* clobbering all FAT entries for this file     */
		/* (or, in English, truncate the FAT).          */
		wipe_out(fnp);
		fnp -> f_dir.dir_size = 0l;
		*(fnp -> f_dir.dir_name) = DELETED;

		/* The directory has been modified, so set the  */
		/* bit before closing it, allowing it to be     */
		/* updated                                      */
		fnp -> f_flags.f_dmod = TRUE;
		dir_close(fnp);

		/* SUCCESSful completion, return it             */
		return SUCCESS;
	}
	else
	{
		/* No such file, return the error               */ 
		dir_close(fnp);
		return DE_FILENOTFND;
	}
}


COUNT 
dos_rmdir (BYTE FAR *path)
{
	REG struct f_node FAR *fnp;
	REG struct f_node FAR *fnp1;
	BOOL found;

	/* first split the passed dir into comopnents (i.e. -   */
	/* path to new directory and name of new directory      */
	if((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL)
	{
		dir_close(fnp);
		return DE_PATHNOTFND;
	}

	/* Check that we're not trying to remove the root!      */
	if((path[0] == '\\') && (path[1] == NULL))
	{
		dir_close(fnp);
		return DE_ACCESS;
	}

	/* Check that we don't have a duplicate name, so if we  */
	/* find one, it's an error.                             */
	if(find_fname(fnp, szFileName, szFileExt))
	{
		/* The only permissable attribute is directory, */
		/* check for any other bit set. If it is, give  */
		/* an access error.                             */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲另类春色国产| 欧美成人艳星乳罩| 亚洲综合在线第一页| 色噜噜久久综合| 亚洲444eee在线观看| 91精品国产乱| 国产在线看一区| 亚洲欧美综合在线精品| 在线观看国产91| 日韩高清一级片| 精品av综合导航| 波多野结衣中文一区| 亚洲综合免费观看高清完整版 | 成人app软件下载大全免费| 国产日产欧美一区二区三区| 不卡一卡二卡三乱码免费网站| 亚洲欧美日韩久久精品| 欧美美女视频在线观看| 国产一区二区久久| 国产精品久久久久aaaa| 欧美日韩精品一二三区| 久久精品久久精品| 亚洲色图.com| 日韩丝袜情趣美女图片| 99在线精品一区二区三区| 亚洲高清免费视频| 久久久av毛片精品| 91玉足脚交白嫩脚丫在线播放| 日韩精彩视频在线观看| 国产亚洲成aⅴ人片在线观看| 色综合天天视频在线观看| 蜜桃av噜噜一区| 亚洲色图丝袜美腿| 欧美变态口味重另类| 91久久线看在观草草青青| 狠狠色狠狠色综合系列| 亚洲综合偷拍欧美一区色| 久久久久久久性| 欧美区视频在线观看| 不卡一区二区中文字幕| 精品一区中文字幕| 亚洲图片欧美视频| 欧美激情艳妇裸体舞| 91精品国产全国免费观看| 波多野结衣精品在线| 国产一区在线视频| 日本在线观看不卡视频| 樱花影视一区二区| 国产三级精品三级在线专区| 欧美一区二区三区四区久久| 91蜜桃网址入口| 国产不卡视频在线播放| 久久精品久久99精品久久| 午夜精品成人在线| 亚洲三级免费观看| 国产精品久久久久7777按摩| 久久精品夜色噜噜亚洲aⅴ| 欧美一区二区三区免费观看视频 | 欧美高清dvd| 色香蕉久久蜜桃| 国产99精品国产| 黄网站免费久久| 奇米影视一区二区三区| 舔着乳尖日韩一区| 一二三区精品视频| 国产精品久久福利| 国产日产欧产精品推荐色| 2020国产精品久久精品美国| 日韩免费观看高清完整版| 欧美区在线观看| 91精品久久久久久久91蜜桃| 欧美日韩美少妇| 欧美日韩国产乱码电影| 欧美视频一区二区三区四区 | 欧美精品欧美精品系列| 在线中文字幕一区二区| 欧美中文字幕一区| 91免费观看国产| 欧美性猛交xxxx黑人交| 欧美无乱码久久久免费午夜一区 | 久久精品国产秦先生| 美女视频黄久久| 久久99精品国产.久久久久久| 乱一区二区av| 狠狠狠色丁香婷婷综合激情 | 综合在线观看色| 亚洲另类春色校园小说| 亚洲亚洲精品在线观看| 五月婷婷激情综合| 蜜臀av一区二区三区| 韩日av一区二区| 欧美午夜理伦三级在线观看| 欧美人牲a欧美精品| 欧美刺激脚交jootjob| 国产欧美日韩精品a在线观看| 欧美国产综合一区二区| 亚洲日韩欧美一区二区在线| 亚洲精品日韩一| 日韩av在线发布| 国产福利一区二区三区在线视频| 成人天堂资源www在线| 色吊一区二区三区| 5月丁香婷婷综合| 欧美激情在线一区二区| 亚洲乱码中文字幕| 天堂午夜影视日韩欧美一区二区| 另类小说视频一区二区| 成人av网在线| 91精品黄色片免费大全| 中文字幕欧美区| 亚洲超碰精品一区二区| 国产精品资源在线| 日本韩国欧美三级| 欧美精品一区二区精品网| 国产欧美日产一区| 亚洲成人一二三| 波多野结衣中文字幕一区二区三区 | 日韩一区二区三区在线| 久久久精品中文字幕麻豆发布| 国产精品青草久久| 一区二区三区成人| 精品在线观看免费| 91猫先生在线| 日韩一区二区免费视频| 国产蜜臀97一区二区三区| 亚洲精品你懂的| 国内精品久久久久影院一蜜桃| 99国产欧美另类久久久精品| 欧美日韩黄色影视| 欧美激情自拍偷拍| 久久精品久久精品| 欧美日韩国产另类不卡| 国产精品灌醉下药二区| 久久精品国产99国产| 欧美午夜电影在线播放| 中文字幕精品—区二区四季| 男男成人高潮片免费网站| 欧美影院精品一区| 国产精品亲子伦对白| 久久99精品网久久| 欧美日韩电影在线| 一区二区三区美女| kk眼镜猥琐国模调教系列一区二区| 精品少妇一区二区三区在线播放| 亚洲一区av在线| 99精品视频在线观看| 国产日韩av一区二区| 精品亚洲aⅴ乱码一区二区三区| 欧美色综合久久| 亚洲精品成a人| 成人免费看视频| 国产午夜精品久久久久久久| 美女视频黄 久久| 欧美成人伊人久久综合网| 日韩电影免费一区| 91精品国产91久久久久久一区二区 | 亚洲自拍偷拍网站| 色系网站成人免费| 亚洲图片另类小说| 91视视频在线直接观看在线看网页在线看| 久久综合网色—综合色88| 人人爽香蕉精品| 精品三级av在线| 韩日av一区二区| 国产无人区一区二区三区| 国产91精品久久久久久久网曝门| 久久综合九色综合97婷婷| 精品一区二区久久| 亚洲精品一线二线三线无人区| 老司机午夜精品| 精品欧美一区二区在线观看 | 国产精品毛片大码女人| 成人中文字幕电影| 亚洲欧美怡红院| 色94色欧美sute亚洲线路一久 | 国产一区二区三区四区五区美女| 精品电影一区二区| 国产精品一卡二卡在线观看| 国产偷国产偷精品高清尤物| jlzzjlzz亚洲女人18| 亚洲婷婷国产精品电影人久久| 91在线观看地址| 亚洲五月六月丁香激情| 日韩欧美色综合网站| 国产一区二区看久久| 国产精品传媒视频| 欧美无砖专区一中文字| 日本不卡1234视频| 欧美激情一区二区三区| 欧美主播一区二区三区美女| 天堂av在线一区| 久久久91精品国产一区二区精品 | 日韩免费成人网| 国产成人午夜精品影院观看视频| 国产精品久久久久久久久久免费看| 色婷婷综合激情| 久久91精品国产91久久小草| 国产精品美女久久久久久2018| 欧美性猛交xxxx乱大交退制版 | 国产精品不卡视频|