📄 file.h
字号:
/*
* @(#)File.h
* @date 2005/12/25
* @version 1.0
* @author Zhou Shangpin.
* Copyright 2005 Anyka corporation, Inc. All rights reserved.
* ANYKA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _FILE_H_
#define _FILE_H_
#include "ustring.h"
#include "driver.h"
#include "list.h"
#include "link.h"
#include "fname.h"
#include "attr.h"
#include "filter.h"
#include "fid.h"
/* define file operation mode */
#define FILE_MODE_READ 0x00
#define FILE_MODE_CREATE 0x01
#define FILE_MODE_OVERLAY 0x02
#define FILE_MODE_APPEND 0x03
typedef struct File T_FILE;
typedef struct File* T_PFILE;
struct File
{
T_OBJECT obj;
T_U32 ptr_high; //read and write pointer 's high 32bit.
T_U32 ptr; //read and write pointer 's low 32bit.
T_U32 BufLenMask; // = sector length - 1.
T_U8* SectorBuf; //file data buffer. len = sector length.
T_U8 mode; //read and write mode. it is useless for dirctory.
T_U8 ClosedFlag; //read and write mode. it is useless for dirctory.
T_PATTR attr; //share attribute, for all object of same file.
};
/*
destroy a file object to free space.
*/
T_VOID File_Destroy(T_PFILE obj);
/*
reflush write data to medium and delete refrence from system.
and destroy a file object to free space.
*/
T_VOID File_Close(T_PFILE file);
/*
open file by a known id. usually the file is directory.
see as File_Open, File_OpenSub, File_OpenNext.
*/
T_PFILE File_OpenId(T_PDRIVER driver, T_U32 id);
/*
open file by abstract path and parent director and read/write mode.
if path is absolute then parent is invalid.
if parent is null then path's parent is system current path.
if path is invalid, return AK_NULL
see as File_OpenId, File_OpenSub, File_OpenNext
*/
T_PFILE File_Open(T_PFILE parent, T_PSTRING path, T_U32 mode);
T_PFILE File_OpenAsc(T_PFILE parent, T_U8*, T_U32 mode);
T_PFILE File_OpenUnicode(T_PFILE parent, T_U16*, T_U32 mode);
/*
get file's absolute path. it include device number, abstract path and last name.
see the member named ShortName of attr object.
*/
T_PSTRING File_GetPath(T_PATTR file);
/*
if file is exist at medium, return AK_TRUE, else return AK_FALSE
*/
T_BOOL File_Exist(T_PFILE file);
/*
if file is exist and file is a directory return AK_TRUE else return AK_FALSE
*/
T_BOOL File_IsFolder(T_PFILE file);
/*
if file is exist and file is a data file return AK_TRUE else return AK_FALSE
*/
T_BOOL File_IsFile(T_PFILE file);
/*
if file is hidden, then return AK_TRUE else return AK_FALSE
*/
T_BOOL File_IsHidden(T_PFILE file);
/*
return file's length low 32 bit. and set high
*/
T_U32 File_GetLength(T_PFILE file, T_U32* high);
//create a new folder.
T_BOOL File_Mkdir(T_PFILE file);
//delete a old file or folder.
T_BOOL File_DeleteFile(T_PFILE file);
//delete a old file or folder.
T_BOOL File_DeleteAsc(T_U8* FileName);
//delete a old file or folder.
T_BOOL File_DeleteUnicode(T_U16* FileName);
//rename or move file
T_BOOL File_RenameTo(T_PFILE source, T_PFILE dest);
//move data file read /write pointer.
T_U32 File_Seek(T_PFILE file, T_U32 pos);
//move data file read /write pointer.
T_U32 File_SeekFill(T_PFILE file, T_U32 pos);
//read a byte from a data file.
T_U16 File_Read(T_PFILE file);
//read block from a data file.
T_U32 File_ReadBlock(T_PFILE file, T_pVOID buf, T_U32 byts);
//write a byte to data file
T_BOOL File_Write(T_PFILE file, T_U8 ch);
//write a block to data file.
T_U32 File_WriteBlock(T_PFILE file, T_pVOID buf, T_U32 size);
//copy file to a folder.
T_PFILE File_CopyFile(T_PFILE file, T_PFILE parent, T_BOOL replace);
//copy some file of source folder to dest folder.
T_U32 File_CopyFolder(T_PFILE source, T_PFILE dest, T_PFILTER filter);
//delete all file and folder of a folder.
T_U32 File_Deltree(T_PFILE folder);
//create a folder, include middle folder.
T_BOOL File_Mkdirs(T_PSTRING path);
T_BOOL File_MkdirsAsc(T_U8* path);
T_BOOL File_MkdirsUnicode(T_U16* path);
//get some file's object of a folder.
T_PLINK File_Dirs(T_PFILE folder, T_PFILTER filter);
//for fat16 interface.
T_PLINK File_Dirs1(T_PFILE parent, T_PFILTER filter);
//open file by id.
T_PFILE File_OpenSub(T_PFILE parent, struct FidData* fid);
//open next file of folder.
T_PFILE File_OpenNext(T_PFILE parent, T_PBLINK link);
//open file by attr.
T_PFILE File_Initial(T_PATTR attr);
//copy a data file to other file.
T_VOID File_CopyData(T_PFILE source, T_PFILE dest);
//flush last data to file.
T_VOID File_Flush(T_PFILE file);
//set defualt path.
T_BOOL File_SetDefault(T_PFILE file);
T_BOOL File_RdAsc(T_U8* path);
T_BOOL File_RdUnicode(T_U16* path);
//create a dma read task.
//T_U32 File_UartRead(T_PFILE fp, T_U8* buf, T_U32 size);
//create a dma write task
//T_U32 File_UartWrite(T_PFILE fp, T_U8* buf, T_U32 size);
//get a task state.
//T_BOOL File_GetUartState(T_U32 TaskID, T_U32* size);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -