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

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

?? fat32_write.c

?? FAT32代碼
?? C
字號:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//					        FAT32 File IO Library
//								    V2.0
// 	  							 Rob Riglar
//						    Copyright 2003 - 2007
//
//   					  Email: rob@robriglar.com
//
//-----------------------------------------------------------------------------
//
// This file is part of FAT32 File IO Library.
//
// FAT32 File IO Library 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 of the License, or
// (at your option) any later version.
//
// FAT32 File IO Library 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 FAT32 File IO Library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include "FAT32_Definitions.h"
#include "FAT32_Base.h"
#include "FAT32_Table.h"
#include "FAT32_Access.h"
#include "FAT32_Write.h"
#include "FAT32_Filestring.h"
#include "FAT32_Misc.h"

#ifdef INCLUDE_WRITE_SUPPORT
//-----------------------------------------------------------------------------
// FAT32_AddFreeSpaceToChain: Allocate another cluster of free space to the end
// of a files cluster chain.
//-----------------------------------------------------------------------------
BOOL FAT32_AddFreeSpaceToChain(UINT32 *startCluster)
{
	UINT32 nextcluster;

	// Set the next free cluster hint to unknown
	FAT32_SetFsInfoNextCluster(0xFFFFFFFF); 

	// Start looking for free clusters from the beginning
	if (FAT32_FindBlankCluster(2, &nextcluster))
	{
		// Point last to this
		FAT32_SetClusterValue(*startCluster, nextcluster);
		
		// Point this to end of file
		FAT32_SetClusterValue(nextcluster, FAT32_EOC_FLAG);

		// Adjust argument reference
		*startCluster = nextcluster;

		return TRUE;
	}
	else
		return FALSE;
}
//-----------------------------------------------------------------------------
// FAT32_AllocateFreeSpace: Add an ammount of free space to a file either from
// 'startCluster' if newFile = false, or allocating a new start to the chain if
// newFile = true.
//-----------------------------------------------------------------------------
BOOL FAT32_AllocateFreeSpace(BOOL newFile, UINT32 *startCluster, UINT32 size)
{
	UINT32 clusterSize;
	UINT32 clusterCount;
	UINT32 nextcluster;

	if (size==0)
		return FALSE;

	// Set the next free cluster hint to unknown
	FAT32_SetFsInfoNextCluster(0xFFFFFFFF); 

	// Work out size and clusters
	clusterSize = FAT32.SectorsPerCluster * 512;
	clusterCount = (size / clusterSize);

	// If any left over
	if (size-(clusterSize*clusterCount))
		clusterCount++;

	// Allocated first link in the chain if a new file
	if (newFile)
	{
		if (!FAT32_FindBlankCluster(2, &nextcluster))
			return FALSE;

		// If this is all that is needed then all done
		if (clusterCount==1)
		{
			FAT32_SetClusterValue(nextcluster, FAT32_EOC_FLAG);
			*startCluster = nextcluster;
			return TRUE;
		}
	}
	// Allocate from end of current chain (startCluster is end of chain)
	else
		nextcluster = *startCluster;

	while (clusterCount)
	{
		if (!FAT32_AddFreeSpaceToChain(&nextcluster))
			return FALSE;

		clusterCount--;
	}

	return TRUE;
}
//-----------------------------------------------------------------------------
// FAT32_FindFreeOffset: Find a free space in the directory for a new entry 
// which takes up 'entryCount' blocks (or allocate some more)
//-----------------------------------------------------------------------------
BOOL FAT32_FindFreeOffset(UINT32 dirCluster, int entryCount, UINT32 *pSector, BYTE *pOffset)
{
	BYTE item=0;
	UINT16 recordoffset = 0;
	int currentCount = entryCount;
	BYTE i=0;
	int x=0;

	BOOL firstFound = FALSE;

	if (entryCount==0)
		return FALSE;

	// Main cluster following loop
	while (TRUE)
	{
		// Read sector
		if (FAT32_SectorReader(dirCluster, x++)) 
		{
			// Analyse Sector
			for (item=0; item<=15;item++)
			{
				// Create the multiplier for sector access
				recordoffset = (32*item);

				// If looking for the last used directory entry
				if (firstFound==FALSE)
				{
					if (FATFS_Internal.currentsector[recordoffset]==0x00)
					{
						firstFound = TRUE;

						// Store start
						*pSector = x-1;
						*pOffset = item;

						currentCount--;
					}
				}
				// Check that there are enough free entries left
				else
				{
					// If everthing fits
					if (currentCount==0)
						return TRUE;
					else
						currentCount--;
				}

			} // End of for
		} // End of if
		// Run out of free space in the directory, allocate some more
		else
		{
			UINT32 newCluster;

			// Get a new cluster for directory
			if (!FAT32_FindBlankCluster(2, &newCluster))
				return FALSE;

			// Add cluster to end of directory tree
			if (!FAT32_AddClusterToEndofChain(dirCluster, newCluster))
				return FALSE;

			// Erase new directory cluster
			memset(FATFS_Internal.currentsector, 0x00, 512);
			for (i=0;i<FAT32.SectorsPerCluster;i++)
			{
				if (!FAT32_SectorWriter(newCluster, i))
					return FALSE;
			}

			// If non of the name fitted on previous sectors
			if (firstFound==FALSE) 
			{
				// Store start
				*pSector = (x-1);
				*pOffset = 0;
				firstFound = TRUE;
			}

			return TRUE;
		}
	} // End of while loop

	return FALSE;
}
//-----------------------------------------------------------------------------
// FAT32_AddFileEntry: Add a directory entry to a location found by FindFreeOffset
//-----------------------------------------------------------------------------
BOOL FAT32_AddFileEntry(UINT32 dirCluster, char *filename, char *shortfilename, UINT32 startCluster, UINT32 size)
{
	BYTE item=0;
	UINT16 recordoffset = 0;
	BYTE i=0;
	UINT32 x=0;
	int entryCount = FATMisc_LFN_to_entry_count(filename);
	FAT32_ShortEntry shortEntry;
	BOOL dirtySector = FALSE;

	UINT32 dirSector = 0;
	BYTE dirOffset = 0;
	BOOL foundEnd = FALSE;

	BYTE checksum;
	BYTE *pSname;

	if (entryCount==0)
		return FALSE;

	// Find space in the directory for this filename (or allocate some more)
	if (!FAT32_FindFreeOffset(dirCluster, entryCount, &dirSector, &dirOffset))
		return FALSE;

	// Generate checksum of short filename
	pSname = (BYTE*)shortfilename;
	checksum = 0;
	for (i=11; i!=0; i--) checksum = ((checksum & 1) ? 0x80 : 0) + (checksum >> 1) + *pSname++;

	// Main cluster following loop
	while (TRUE)
	{
		// Read sector
		if (FAT32_SectorReader(dirCluster, x++)) 
		{
			// Analyse Sector
			for (item=0; item<=15;item++)
			{
				// Create the multiplier for sector access
				recordoffset = (32*item);

				// If the start position for the entry has been found
				if (foundEnd==FALSE)
					if ( (dirSector==(x-1)) && (dirOffset==item) )
						foundEnd = TRUE;

				// Start adding filename
				if (foundEnd)
				{				
					if (entryCount==0)
					{
						// Short filename
						FATMisc_Create_sfn_entry(shortfilename, size, startCluster, &shortEntry);
						memcpy(&FATFS_Internal.currentsector[recordoffset], &shortEntry, sizeof(shortEntry));

						// Writeback
						return FAT_WriteSector(FATFS_Internal.SectorCurrentlyLoaded, FATFS_Internal.currentsector);
					}
					else
					{
						entryCount--;

						// Copy entry to directory buffer
						FATMisc_LFN_to_lfn_entry(filename, &FATFS_Internal.currentsector[recordoffset], entryCount, checksum); 
						dirtySector = TRUE;
					}
				}
			} // End of if

			// Write back to disk before loading another sector
			if (dirtySector)
			{
				if (!FAT_WriteSector(FATFS_Internal.SectorCurrentlyLoaded, FATFS_Internal.currentsector))
					return FALSE;

				dirtySector = FALSE;
			}
		} 
		else
			return FALSE;
	} // End of while loop

	return FALSE;
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91片黄在线观看| 日韩精品专区在线影院重磅| 欧美一区二区三区电影| 国产女主播一区| 日韩电影在线观看网站| 91在线一区二区三区| 久久女同精品一区二区| 日韩精品亚洲专区| 91九色02白丝porn| 国产精品嫩草影院com| 精久久久久久久久久久| 欧美精品第1页| 亚洲一区二区三区视频在线 | 久久久久久一二三区| 婷婷夜色潮精品综合在线| 一本到三区不卡视频| 亚洲欧美综合另类在线卡通| 国产福利91精品一区二区三区| 538在线一区二区精品国产| 一二三四社区欧美黄| 99国产一区二区三精品乱码| 欧美国产日产图区| 成人黄色777网| 亚洲欧美综合在线精品| 成人黄色国产精品网站大全在线免费观看| 精品国产一区二区三区忘忧草| 日韩在线a电影| 欧美一区二区三区影视| 日本大胆欧美人术艺术动态 | 久久久久久久久久久99999| 久久99精品久久久久久久久久久久 | 欧美精品视频www在线观看| 亚洲二区在线观看| 欧美日韩大陆一区二区| 亚洲国产日韩综合久久精品| 8x8x8国产精品| 蜜臀av性久久久久蜜臀aⅴ| 欧美成人精品二区三区99精品| 久久99久久精品欧美| 26uuu成人网一区二区三区| 国产精品资源网站| 综合网在线视频| 91国偷自产一区二区三区观看| 亚洲小说春色综合另类电影| 91精品国产品国语在线不卡| 韩国精品一区二区| 日韩一区中文字幕| 欧洲人成人精品| 久久99最新地址| 久久精品欧美日韩| 色婷婷av一区二区三区软件 | 三级亚洲高清视频| 精品国产1区2区3区| zzijzzij亚洲日本少妇熟睡| 亚洲影院免费观看| 精品少妇一区二区三区在线播放| 国产精品一卡二卡| 亚洲精品视频在线| 精品久久国产字幕高潮| 99在线热播精品免费| 日韩av一区二区在线影视| 久久亚洲一区二区三区明星换脸| 99久久国产综合精品色伊| 日韩电影在线免费看| 国产午夜精品一区二区三区四区| 91久久精品国产91性色tv| 久久精品国产免费| 亚洲激情男女视频| 精品蜜桃在线看| 一本到不卡免费一区二区| 国产在线一区观看| 亚洲444eee在线观看| 久久精品视频一区| 911精品国产一区二区在线| 99久久精品国产麻豆演员表| 另类的小说在线视频另类成人小视频在线| 国产精品色呦呦| 日韩一区二区免费在线观看| 一本色道久久综合亚洲aⅴ蜜桃| 男女男精品视频| 一区二区三区不卡视频在线观看 | 国产盗摄精品一区二区三区在线| 亚洲午夜三级在线| 中文字幕视频一区| 久久久久久99精品| 欧美一级高清大全免费观看| 在线免费观看视频一区| 国产在线播精品第三| 丝袜亚洲另类欧美综合| 亚洲日本免费电影| 国产视频一区二区三区在线观看 | 国产一区在线精品| 日韩vs国产vs欧美| 午夜精品一区二区三区三上悠亚| 亚洲欧洲日韩一区二区三区| 国产情人综合久久777777| 久久一区二区视频| 欧美va亚洲va| 91精品国产一区二区三区| 欧美日韩色综合| 91精品1区2区| 91丝袜美腿高跟国产极品老师| 懂色av一区二区在线播放| 国产成人在线网站| 国产一区二区毛片| 久久国产精品无码网站| 蜜臀精品久久久久久蜜臀 | www.欧美色图| 成人高清免费在线播放| 国产黄色精品视频| 国产成人h网站| 成人禁用看黄a在线| 成人av在线观| 97se亚洲国产综合在线| 日本高清不卡aⅴ免费网站| 91玉足脚交白嫩脚丫在线播放| 91丨九色porny丨蝌蚪| 色综合久久九月婷婷色综合| 色婷婷国产精品久久包臀| 在线观看视频一区二区| 欧美欧美欧美欧美首页| 精品国产一区a| 久久综合久久久久88| 国产欧美一区二区三区网站| 中文字幕中文字幕中文字幕亚洲无线| 国产精品美女久久福利网站| 亚洲丝袜另类动漫二区| 亚洲成人免费观看| 老司机精品视频导航| 国产精品66部| 色婷婷综合久久久久中文 | 韩国女主播成人在线| 国产精品中文字幕一区二区三区| 成人免费视频一区二区| 99riav一区二区三区| 欧美日韩一区视频| 久久久亚洲高清| 亚洲日本欧美天堂| 蜜桃久久av一区| 成人国产精品免费| 欧美日韩视频在线第一区| 精品久久国产老人久久综合| 日韩理论片一区二区| 视频一区二区欧美| 懂色av一区二区三区免费看| 精品视频资源站| 国产偷国产偷亚洲高清人白洁| 亚洲欧美另类小说| 激情综合网天天干| 色婷婷香蕉在线一区二区| 日韩视频在线你懂得| 国产精品电影一区二区| 日日夜夜免费精品| 91浏览器打开| 久久色中文字幕| 亚洲福中文字幕伊人影院| 处破女av一区二区| 日韩一级成人av| 亚洲电影第三页| 99国产精品久久久久久久久久| 日韩视频永久免费| 亚洲国产中文字幕| 大尺度一区二区| 久久一区二区三区国产精品| 午夜不卡av免费| 91九色最新地址| 国产精品久久福利| 激情久久五月天| 91精品国产91久久久久久一区二区 | 91麻豆国产自产在线观看| 日韩精品中文字幕一区二区三区| 亚洲乱码国产乱码精品精可以看| 狠狠色狠狠色综合| 日韩一区二区三区精品视频| 亚洲品质自拍视频| 成人黄色av电影| 久久久久久久国产精品影院| 麻豆精品视频在线| 欧美日韩不卡一区| 亚洲主播在线观看| 91麻豆文化传媒在线观看| 国产欧美一区二区三区网站| 麻豆91精品视频| 91精品国产手机| 丝袜美腿成人在线| 欧美精品日日鲁夜夜添| 亚洲一区二区偷拍精品| 色妹子一区二区| 日韩伦理免费电影| 色婷婷av一区二区三区大白胸| 国产精品视频在线看| 成人性生交大合| 亚洲国产精品二十页| 成人激情小说网站| 国产精品女主播av| 91偷拍与自偷拍精品| 亚洲激情自拍偷拍| 欧美日韩精品二区第二页| 亚洲午夜免费福利视频| 91麻豆精品国产91久久久更新时间|