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

📄 fal.h

📁 NUcleus plus 支持的文件系统。 是学习文件系统的很好参考资料。
💻 H
字号:
/***************************************************************************
*
*    Copyright (c)  1993 - 2002 Accelerated Technology, Inc.
*
* PROPRIETARY RIGHTS of Accelerated Technology are involved in the subject
* matter of this material.  All manufacturing, reproduction, use and sales
* rights pertaining to this subject matter are governed by the license
* agreement.  The recipient of this software implicity accepts the terms
* of the license.
*
****************************************************************************/
/****************************************************************************
*
*  FILENAME                                                 VERSION
*
*      FAL.H                                                1.5.5
*
*  COMPONENT
*
*       File Abstraction Layer
*
*  DESCRIPTION
*
*      This file contains the File Abstraction Layer function prototypes
*      and miscellaneous defines.
*
*   DATA STRUCTURES
*
*       timev       Stores time and date
*
*   FUNCTIONS
*
*       None
*
*   DEPENDENCIES
*
*       nucleus.h
*       target.h
*       pcdisk.h
*       proto.h
*       windows.h
*       io.h
*       time.h
*       fcntl.h
*       stat.h
*       direct.h
*       winbase.h
*       imf.h
*
****************************************************************************/

#ifndef FAL_H
#define FAL_H

#include "plus/nucleus.h"
#include "net/target.h"
#include "net/inc/externs.h"
#include "net/inc/socketd.h"

#ifdef          __cplusplus
extern  "C" {                               /* C declarations in C++     */
#endif /* _cplusplus */

#define NUCLEUS_FILE_INCLUDED   0
#define NUCLEUS_FILE2_INCLUDED  1
#define NT_FILE_SYSTEM          0
#define IMF_INCLUDED            0

#define TEST_FILE_SYSTEMS (NUCLEUS_FILE_INCLUDED + NUCLEUS_FILE2_INCLUDED + NT_FILE_SYSTEM + IMF_INCLUDED)

#if (TEST_FILE_SYSTEMS > 1)
#error Incorrect settings for the file system to be used by FAL! Only one file system may be selected.
#endif

#if (NUCLEUS_FILE_INCLUDED || NUCLEUS_FILE2_INCLUDED)
#include "file/pcdisk.h"
#endif

#if NT_FILE_SYSTEM
#include <windows.h>
#include <io.h>
#include <time.h>
#include <fcntl.h>      /* Required for write and read flags */
#include <sys/stat.h>   /* Required for write and read mode */
#include <direct.h>
#include <winbase.h>
#endif

#if IMF_INCLUDED
#include "fal/inc/imf.h"
#endif

/* This structure is used by all four file systems */
typedef struct timev
{
   INT tm_hour;
   INT tm_min;
   INT tm_sec;
   INT tm_mon;
   INT tm_mday;
   INT tm_year;
} tm_time;

#if (NUCLEUS_FILE_INCLUDED || NUCLEUS_FILE2_INCLUDED || IMF_INCLUDED)
/* These aliases define the bit positions within File's DATESTR */
#define YEARMASK    0xFE00
#define MONTHMASK   0x01E0
#define DAYMASK     0x001F
#define HOURMASK    0xF800
#define MINMASK     0x07C0
#define SECMASK     0x003F
#endif

#if IMF_INCLUDED
#define FAL_FILE    INT
#define FAL_DIR     MEM_FILE
#define FAL_TIME    UNSIGNED
#define FAL_LOCAL   tm_time
#define FAL_EOF     -1

#ifndef __PCDISK__

#define UTINY       UCHAR

#define PO_RDONLY 0x0000                /* Open for read only*/
#define PO_WRONLY 0x0001                /* Open for write only*/
#define PO_RDWR   0x0002                /* Read/write access allowed.*/
#define PO_APPEND 0x0008                /* Seek to eof on each write*/
#define PO_CREAT  0x0100                /* Create the file if it does not exist.*/
#define PO_TRUNC  0x0200                /* Truncate the file if it already exists*/
#define PO_EXCL   0x0400                /* Fail if creating and already exists*/
#define PO_TEXT   0x4000                /* Ignored*/
#define PO_BINARY 0x8000                /* Ignored. All file access is binary*/
#define PO_NOSHAREANY   0x0004          /* Wants this open to fail if already
                                         * open.  Other opens will fail while
                                         * this open is active */
#define PO_NOSHAREWRITE 0x0800          /* Wants this opens to fail if already
                                         * open for write. Other open for
                                         * write calls will fail while this
                                         * open is active. */

/* The following MACROS are defined for the purpose of building the
 * FTP Server when IMF is being used.  The FTP Server will not properly
 * function using IMF.
 */
#define AVOLUME 0x8
#define ADIRENT 0x10
#define PEBADF  9
#define PENOENT 2
#define PEMFILE 24
#define PEEXIST 17
#define PEACCES 13
#define PEINVAL 22
#define PENOSPC 28
#define PESHARE 30

#endif

#define FAL_IWRITE 0000400              /* Write Mode for Nucleus File */
#define FAL_IREAD  0000200

#define FILE_CHECK          -1           /* File Initialized Value For Nucleus File     */

#endif

#if NT_FILE_SYSTEM

#ifndef __PCDISK__

/* NUCLEUS FILE FLAG        CORRESPONDING NT FLAG */
#define PO_RDONLY           _O_RDONLY
#define PO_WRONLY           _O_WRONLY
#define PO_RDWR             _O_RDWR
#define PO_APPEND           _O_APPEND
#define PO_CREAT            _O_CREAT
#define PO_TRUNC            _O_TRUNC
#define PO_EXCL             _O_EXCL
#define PO_TEXT             _O_TEXT
#define PO_BINARY           _O_BINARY

/* NUCLEUS FILE SEEK START  CORRESPONDING NT SEEK START */
#define PSEEK_CUR           SEEK_CUR
#define PSEEK_END           SEEK_END
#define PSEEK_SET           SEEK_SET

/* NUCLEUS FILE ERROR       CORRESPONDING NT ERROR */
#define PEBADF              ERROR_INVALID_HANDLE
#define PENOSPC             ERROR_DISK_FULL
#define PENOENT             ERROR_FILE_NOT_FOUND
#define PEMFILE             ERROR_TOO_MANY_OPEN_FILES
#define PEEXIST             ERROR_FILE_EXISTS
#define PEACCES             ERROR_CANTREAD
#define PEINVAL             ERROR_NEGATIVE_SEEK

/* File Attributes */
#define AVOLUME 0x8
#define ADIRENT 0x10

#endif

/* NUCLEUS FILE MODE        CORRESPONDING NT MODE */
#define FAL_IWRITE          _S_IWRITE
#define FAL_IREAD           _S_IREAD

#define FAL_EOF             EOF

/* Define specific FAL data types to the corresponding NT data type */
#define FAL_FILE        INT
#define FAL_DIR         struct _finddata_t
#define FAL_TIME        time_t
#define FAL_LOCAL       struct tm

#define FILE_CHECK          -1           /* File Initialized Value For Nucleus File     */
#define CTIME_BUFFER_SIZE   26

#endif

#if NUCLEUS_FILE_INCLUDED
#define __RAM "A:"
#define FAL_FILE        PCFD        /* Set Nucleus File Descriptor type            */
#define FAL_DIR         DSTAT       /* Set Nucleus File structure type             */
#define FAL_TIME        UNSIGNED    /* Set Nucleus File Time value                 */
#define FAL_LOCAL       tm_time     /* Set local time type                         */
#define FILE_CHECK     -1           /* File Initialized Value For Nucleus File     */
#define FAL_EOF        -1           /* End of File Value for Nucleus File          */

#define FAL_IWRITE 0000400              /* Write Mode for Nucleus File */
#define FAL_IREAD  0000200

BOOL    RAM_disk_init(VOID);

IMPORT  PFILE_SYSTEM_USER fs_current_user_structure(VOID);
extern  INT NUFP_Initialize(VOID);
#endif

#if NUCLEUS_FILE2_INCLUDED
#define FAL_FILE        INT         /* Set Nucleus File Descriptor type            */
#define FAL_DIR         DSTAT       /* Set Nucleus File structure type             */
#define FAL_TIME        UNSIGNED    /* Set Nucleus File Time value                 */
#define FAL_LOCAL       tm_time     /* Set local time type                         */
#define FILE_CHECK     -1           /* File Initialized Value For Nucleus File     */
#define FAL_EOF        -1           /* End of File Value for Nucleus File          */

#define FAL_IWRITE 0000400              /* Write Mode for Nucleus File */
#define FAL_IREAD  0000200

extern  INT NUFP_Initialize(VOID);
#endif

/* Function Prototypes */

FAL_FILE    FAL_Open(CHAR *path, UINT16 flag, UINT16 mode);
INT32       FAL_Fprintf(FAL_FILE file, CHAR *string);
INT         FAL_Fclose(FAL_FILE file, INT iotype);
INT32       FAL_Seek(FAL_FILE file, INT32 offset, INT16 origin);
INT         FAL_Find_Next(FAL_DIR *statobj, INT32 hfile);
INT         FAL_Find_First(CHAR *path, FAL_DIR *statobj, INT32 *attrib);
INT         FAL_Remove(CHAR *name);
INT         FAL_Find_Close(INT32 hfile, FAL_DIR *statobj);
UINT32      FAL_Fwrite(CHAR *buf, UINT16 size, FAL_FILE file);
UINT32      FAL_Fread(CHAR *buf, UINT16 size, FAL_FILE file);
INT         FAL_Mk_Dir(CHAR *mb);
INT         FAL_Rmv_Dir(CHAR *path);
INT         FAL_Is_Dir(CHAR *path);
INT         FAL_Set_Curr_Dir(CHAR *path);
INT         FAL_Current_Dir(INT drive, CHAR *path);
INT         FAL_Rename_File(CHAR *rename_path, CHAR *curr_name);
INT         FAL_Time(FAL_TIME *ltime);
INT         FAL_Ctime(FAL_TIME *ltime, CHAR *buffer);
INT         FAL_Local_Time(FAL_TIME *timer,FAL_LOCAL *time);
INT         FAL_Store_Name(CHAR *name, FAL_DIR *r_file);
INT         FAL_Sys_Init(INT ram_disk);
UINT32      FAL_Object_File_Length(FAL_DIR *file);
UINT32      FAL_Handle_File_Length(FAL_FILE file_desc);
UINT32      FAL_Disk_Space(VOID);
INT         FAL_Get_Curr_Drive(VOID);
INT         FAL_Set_Curr_Drive(INT drive);
INT         FAL_Open_Disk(INT drive);
INT         FAL_Close_Disk(INT drive);
INT         FAL_Release_File_User(VOID);
INT         FAL_Become_File_User(VOID);
signed char FAL_Get_Attribute(FAL_DIR statobj);
INT         FAL_Get_Last_Error(VOID);
tm_time     FAL_Object_Mod_Time(FAL_DIR *);

#ifdef          __cplusplus
}
#endif /* _cplusplus */

#endif /* #ifndef FAL_H */

⌨️ 快捷键说明

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