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

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

?? fatfs.c

?? DOS操作系統源代碼,研究操作系統用. 包括了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一区二区三区免费野_久草精品视频
国产精品久久久久久久久快鸭 | 中文字幕的久久| 日韩毛片精品高清免费| 久久国产精品区| 91黄色激情网站| 国产欧美va欧美不卡在线| 午夜免费欧美电影| 97久久超碰国产精品电影| 日韩欧美www| 亚洲高清免费视频| 99国产精品久久久久久久久久| 精品国产亚洲在线| 秋霞影院一区二区| 欧美日产国产精品| 亚洲男人的天堂一区二区| 国产成人免费网站| 久久日一线二线三线suv| 亚洲福利国产精品| 欧美在线观看一区| 亚洲欧美乱综合| 99视频超级精品| 欧美国产精品久久| 国产成人av一区二区| 精品国产髙清在线看国产毛片| 性久久久久久久久| 欧美人xxxx| 五月综合激情婷婷六月色窝| 日本大香伊一区二区三区| 国产精品视频yy9299一区| 国产精品69毛片高清亚洲| 日韩欧美的一区二区| 久久精品国产在热久久| 日韩欧美视频一区| 精品一区中文字幕| 久久麻豆一区二区| 国产一区二区电影| 国产欧美日韩不卡免费| 成人精品高清在线| 国产精品福利av | 久久精品噜噜噜成人av农村| 欧美一区二区三区视频免费| 丝袜亚洲另类欧美| 日韩午夜激情av| 国产成人av影院| 国产欧美va欧美不卡在线 | 国精产品一区一区三区mba视频| 国产精品一二三在| 国产日韩v精品一区二区| 欧美综合亚洲图片综合区| 亚洲久草在线视频| 91国偷自产一区二区开放时间| 亚洲欧美日韩在线不卡| 91福利资源站| 日本成人中文字幕在线视频| 欧美电影免费观看高清完整版| 韩国一区二区视频| 国产欧美日韩精品一区| 91久久线看在观草草青青| 午夜伊人狠狠久久| 久久亚洲精精品中文字幕早川悠里| 成人性色生活片| 亚洲va韩国va欧美va| 精品少妇一区二区三区| 99综合影院在线| 亚洲一区二区在线视频| 日韩欧美国产麻豆| 91麻豆国产自产在线观看| 午夜不卡av免费| 国产欧美久久久精品影院| 欧美午夜一区二区| 国产精品一级片在线观看| 亚洲一级二级三级| 亚洲精品在线免费观看视频| 91麻豆精品在线观看| 麻豆成人av在线| 亚洲欧美电影院| 精品伦理精品一区| 日本福利一区二区| 国产激情视频一区二区在线观看| 亚洲综合一区二区精品导航| 久久精品人人做人人综合| 欧美系列亚洲系列| av一二三不卡影片| 久久精品国产成人一区二区三区| 亚洲日本丝袜连裤袜办公室| 亚洲精品国产一区二区精华液| 欧美一级理论片| 在线观看亚洲精品视频| 国产毛片一区二区| 日本中文字幕一区二区视频| 国产精品嫩草久久久久| 日韩欧美的一区| 欧美日韩视频在线第一区| 丁香亚洲综合激情啪啪综合| 免费久久99精品国产| 亚洲国产日韩在线一区模特| 中文字幕中文字幕一区二区| 精品久久国产字幕高潮| 欧美性一区二区| 99re6这里只有精品视频在线观看| 国产一区 二区| 久久成人综合网| 日韩激情中文字幕| 亚洲一卡二卡三卡四卡五卡| 国产精品电影一区二区三区| 国产欧美日韩中文久久| 久久久无码精品亚洲日韩按摩| 欧美二区乱c少妇| 在线观看亚洲一区| 欧美在线观看禁18| 色94色欧美sute亚洲线路二 | 国模娜娜一区二区三区| 蜜臀国产一区二区三区在线播放| 亚洲一二三区视频在线观看| 亚洲你懂的在线视频| 日韩久久一区二区| 久久成人免费电影| 美女视频黄免费的久久| 美国三级日本三级久久99 | 精品国产亚洲在线| 久久久精品综合| 精品国精品国产| 久久久久国产成人精品亚洲午夜| 精品福利二区三区| www久久久久| 国产精品免费视频一区| 亚洲视频狠狠干| 亚洲最色的网站| 日韩激情视频网站| 久久成人精品无人区| 国产成人综合在线观看| 国产成人精品网址| 91一区二区在线观看| 欧美日韩日日骚| 日韩欧美视频一区| 国产欧美精品区一区二区三区| 亚洲婷婷在线视频| 午夜精品久久一牛影视| 久久av资源站| 国产成人精品亚洲午夜麻豆| 色狠狠av一区二区三区| 欧美一区二区在线不卡| 国产亚洲欧美日韩日本| 亚洲免费在线观看视频| 日本一区中文字幕 | 国产精品区一区二区三| 亚洲自拍与偷拍| 精品亚洲欧美一区| 91啪在线观看| 欧美一区二区三区免费在线看 | 日韩精品一区二区三区视频播放 | 在线电影院国产精品| 欧美精品一区二区不卡| 亚洲欧美日韩久久| 蜜乳av一区二区三区| 99久久精品免费看| 日韩欧美中文字幕精品| 国产精品福利影院| 精品在线一区二区三区| 色视频欧美一区二区三区| 日韩欧美一级二级三级久久久| 亚洲欧洲在线观看av| 欧美亚洲禁片免费| 欧美精品一区二| 亚洲h精品动漫在线观看| 国产精品亚洲午夜一区二区三区| 在线免费亚洲电影| 中文字幕av一区二区三区| 天天影视网天天综合色在线播放| 国产91精品免费| 日韩欧美一区二区久久婷婷| 一区二区三区日韩| 成人激情免费网站| 久久夜色精品一区| 热久久国产精品| 欧美群妇大交群的观看方式| 综合久久给合久久狠狠狠97色| 精品一区二区三区视频在线观看| 欧美在线观看视频在线| 中文字幕在线不卡一区二区三区| 久久99精品一区二区三区三区| 欧美亚洲一区三区| 自拍视频在线观看一区二区| 国产老肥熟一区二区三区| 欧美一区二区三区成人| 亚洲高清在线视频| 欧美婷婷六月丁香综合色| 日韩一区在线播放| 成年人午夜久久久| 国产亚洲欧美日韩在线一区| 国产在线视视频有精品| 欧美mv日韩mv亚洲| 免费成人美女在线观看| 欧美精品 日韩| 午夜精品福利一区二区三区av | 欧美不卡一区二区三区四区| 亚洲国产va精品久久久不卡综合| 91麻豆swag| 亚洲乱码国产乱码精品精98午夜| 99热在这里有精品免费|