📄 fdi_file.h
字号:
***************************************************************************/
#ifndef FDI_FILE_H
#define FDI_FILE_H
#include <stdio.h>
#if (FILE_MANAGER == TRUE)
/* ### Local Declarations
* ################################# */
/* names for bits in st_mode
*/
#define S_IRWXU 0x01c0 /* RWE permissions mask for owner */
#define S_IRUSR 0x0100 /* owner may read */
#define S_IWUSR 0x0080 /* owner may write */
#define S_IXUSR 0x0040 /* owner may execute <directory search> */
#define S_IRWXG 0x0038 /* RWE permissions mask for group */
#define S_IRGRP 0x0020 /* group may read */
#define S_IWGRP 0x0010 /* group may write */
#define S_IXGRP 0x0008 /* group may execute <directory search> */
#define S_IRWXW 0x0007 /* RWE permissions mask for world */
#define S_IRWLD 0x0004 /* world may read */
#define S_IWWLD 0x0002 /* world may write */
#define S_IXWLD 0x0001 /* world may execute <directory search> */
/*
* sleep(n): replace with appropriate delay...
* This value '60' was set based on the ARM clock speed
*/
/*E.5.0.604.START*/
#define fdi_sleep(n) TaskDelay(60/n) /* taskDelay(60/n) */
/* Modified by jjs from
taskDelay to TaskDelay */
/*E.5.0.604.END*/
#define TASK_DELAY 20 /* used as input to sleep
* macro... delay is
* equivalent to 50ms */
/* Constants for Origin indicating the position relative to which fseek
* sets the file position. Enclosed in ifdefs because the OS may have these
defined in their file system */
#ifndef SEEK_SET
#define SEEK_SET (0)
#endif
#ifndef SEEK_CUR
#define SEEK_CUR (1)
#endif
#ifndef SEEK_END
#define SEEK_END (2)
#endif
/*
* gettime(): replace with appropriate OS actual time function
* to stamp the files with
*/
#define gettime() FileGetTime()
/*
* getdate(): replace with appropriate OS actual date function
* to stamp the files with
*/
#define getdate() FileGetDate()
/*
* getgid(): replace with appropriate OS actual getgid function
*/
#define getgid() FileGetGID()
/*
* getuid(): replace with appropriate OS actual getuid function
*/
#define getuid() FileGetUID()
/* ### Global Declarations
* ################################# */
typedef WORD FILE_ID; /* identifier for the file stream */
typedef struct tag_file_info
{
char file_name[FILE_NAME_SIZE + 1]; /* filename plus null char */
int time; /* updated time stamp when modified */
int date; /* updated date stamp when modified */
DWORD size; /* size of file data in bytes */
WORD owner_id;
WORD group_id;
WORD permissions;
FILE_ID data_id; /* FDI identifier for file data */
/* the following fields are needed for power loss recovery */
FILE_ID plr_id; /* used for power loss recovery */
int plr_time; /* used for power loss recovery */
int plr_date; /* used for power loss recovery */
DWORD plr_size; /* used for power loss recovery */
} FILE_INFO;
/*
* USAGE:
* file_identifier = FDI_fopen(filename_ptr, wb);
*/
FILE_ID FDI_fopen(const char *, const char *);
/*
* USAGE:
* actual_written = FDI_fwrite(&new_struct, sizeof(NEW_STRUCT), 1, file_id);
*/
size_t FDI_fwrite(const void *, size_t, size_t, FILE_ID);
/* USAGE:
* actual_read = FDI_fread(&new_struct, sizeof(NEW_STRUCT), 1, stream_id);
*/
size_t FDI_fread(void *, size_t, size_t, FILE_ID);
/*
* USAGE:
* close_status = FDI_fclose(stream_identifier);
*/
int FDI_fclose(FILE_ID);
/*
* USAGE:
* status = FDI_fseek(stream_identifier, offset, wherefrom);
*/
int FDI_fseek(FILE_ID, long, int);
/*
* USAGE:
* status = FDI_findfirst("*.ext", &the_file_info);
*/
int FDI_findfirst(const char *, FILE_INFO *);
/*
* USAGE:
* status = FDI_findnext(&the_file_info);
*/
int FDI_findnext(FILE_INFO *);
/*
* USAGE:
* status = FDI_remove("test.ext");
*/
int FDI_remove(const char *);
/*
* USAGE:
* status = FDI_rename("test.ext", "mytest.ext");
*/
int FDI_rename(const char *, const char *);
/*
* USAGE:
* status = FDI_fileinit(data_stream_enable);
*/
int FDI_fileinit(int);
/*
* USAGE:
* status = FDI_feof(stream);
*/
int FDI_feof(FILE_ID);
/*
* USAGE:
* fdi_status = FDI_ferror(stream);
*/
ERR_CODE FDI_ferror(FILE_ID);
/*
* USAGE:
* FDI_clearerr(stream);
*/
void FDI_clearerr(FILE_ID);
/*
* function: CHMOD - changes file access mode
*
* syntax: int FDI_chmod(const char *path, int st_mode);
*/
int FDI_chmod(const char *, int);
/*
* function: STAT - gets permissions on file
*
* syntax: int FDI_stat(char *path, int *mode_buf);
*/
int FDI_stat(const char *, int *);
/*
* function: FCHMOD - changes open file access mode
*
* syntax: int FDI_fchmod(FILE_ID open_file, int st_mode);
*/
int FDI_fchmod(FILE_ID, int);
/*
* function: FSTAT - gets permissions on the open file
*
* syntax: int FDI_fstat(FILE_ID open_file, int *mode_buf);
*/
int FDI_fstat(FILE_ID, int *);
/*
* function: FTELL - gets open file's file pointer
*
* syntax: int FDI_ftell(FILE_ID open_file);
*/
long int FDI_ftell(FILE_ID);
/*
* USAGE:
* status = FDI_fileterminate();
*/
int FDI_fileterminate(void);
#endif /* FILE_MANAGER */
#endif /* FDI_FILE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -