⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_fun.c

📁 凌阳SPCE3200 系统开发板随机自带源程序。共安排了32个子目录
💻 C
字号:
/******************************************************************************
 *
 *     The information contained herein is the exclusive property of
 *   Sunplus Technology Co. And shall not be distributed, reproduced,
 *   or disclosed in whole in part without prior written permission.
 *
 *         (C) COPYRIGHT 2006   SUNPLUS TECHNOLOGY CO.
 *                        ALL RIGHTS RESERVED
 *
 * The entire notice above must be reproduced on all authorized copies.
 *
 *****************************************************************************/

/******************************************************************************
 *  Filename:   	FS_fun.c
 *  Author:     	Robin.Lau  (eMail: xjliu@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2006-05-23
 *  Description:	some useful fs functions
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2006-05-23           xjliu               Create
 *
 *****************************************************************************/
#include "FS_fun.h"

struct f_info g_stFileTbl[MAXFILENUM];	//note information of one type files(name,modify time&date,size)
U16 g_nFileNum;							//note the number of one type files
SPG_Time g_stFileTime;				//note modify time of an appointed file
SPG_Date g_stFileDate;				//note modify date of an appointed file

/**
 * FS_ListFile - list all files in the storage device according to wildcard
 * char *wildcard: the path and wildcard
 */
void FS_ListFile(char *wildcard)
{
	//initialize file system
//	fs_init();
	
//	if( fs_mount(1) )
//		while(1);

	//clear file Number
	g_nFileNum = 0;
	
	if(ufat_findfirst(wildcard, &g_stFileTbl[g_nFileNum], D_ALL))
	{
		//No such file
		while(1);
	}

	do{
		g_nFileNum ++;
	}while( ufat_findnext(&g_stFileTbl[g_nFileNum]) == 0 );
}
//
/**
 * FS_GetFileName - get the name of the appointed file
 * U16 index: the index in the g_stFileTbl
 * RETURN: the pointer of name string
 *         NULL: no such file
 */
char* FS_GetFileName(U16 index)
{
	if(index < g_nFileNum)
		return &g_stFileTbl[index].f_name[0];
	
	return NULL;
}

/**
 * FS_GetModifyTime - get modify time of an appointed file
 * U16 index: the index in the g_stFileTbl
 */
//void FS_GetModifyTime(U16 index)
//{
//	U32 tmp;
//
//	//clear
//	*(U32*)(&g_stFileTime) = 0;
//
//	if(index >= g_nFileNum)
//		return;
//
//	//get time
//	tmp = (g_stFileTbl[index].f_time << 1);
//	*(U32*)(&g_stFileTime) = tmp;
//}
//
/**
 * FS_GetModifyDate - get modify date of an appointed file
 * U16 index: the index in the g_stFileTbl
 */
//void FS_GetModifyDate(U16 index)
//{
//	U32 tmp;
//
//	//clear
//	*(U32*)(&g_stFileDate) = 0;
//
//	if(index >= g_nFileNum)
//		return;
//
//	//get date
//	tmp = g_stFileTbl[index].f_date;
//	g_stFileDate.dd = tmp & 0x0000001F;
//	g_stFileDate.mm = (tmp >> 5) & 0x0000000F;
//	g_stFileDate.yy = ((tmp >> 9) & 0x0000007F) + 1980;
//}
//
/**
 * FS_GetFileSize - get the size of the appointed file
 * U16 index: the index in the g_stFileTbl
 * RETURN: file size(unit: Byte)
 *         0xffffffff: no such file
 */
unsigned long FS_GetFileSize(U16 index)
{
	if(index < g_nFileNum)
		return g_stFileTbl[index].f_size;
	
	return 0xffffffff;
}

/**
 * FS_TotalSize - get the total size of storage device
 * RETURN: total size(unit: Byte)
 */
//unsigned long FS_TotalSize(void)
//{
//    struct _diskfree_t diskinfo;
//    unsigned long total_cluster;
//	//unsigned long sperc;
//	//unsigned long bpers;
//	unsigned long totalsize;
//	
//	if(_getdiskfree(0, &diskinfo))
//		while(1);
//	total_cluster = diskinfo.total_clusters+13;
//	//sperc = diskinfo.sectors_per_cluster;
//	//bpers = diskinfo.bytes_per_sector;
//	totalsize = total_cluster * diskinfo.sectors_per_cluster * diskinfo.bytes_per_sector;
//
//	return totalsize;
//}
//
///**
// * FS_FreeSize - get the free size of storage device
// * RETURN: free size(unit: Byte)
// */
//unsigned long FS_FreeSize(void)
//{
//    struct _diskfree_t diskinfo;
//    unsigned long free_cluster;
//	//unsigned long sperc;
//	//unsigned long bpers;
//	unsigned long freesize;
//	
//	if(_getdiskfree(0, &diskinfo))
//		while(1);
//	free_cluster = diskinfo.avail_clusters+15;
//	//sperc = diskinfo.sectors_per_cluster;
//	//bpers = diskinfo.bytes_per_sector;
//	freesize = free_cluster * diskinfo.sectors_per_cluster * diskinfo.bytes_per_sector;
//
//	return freesize;
//}
//


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -