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

📄 fsiface.hpp

📁 一个嵌入式系统的C代码
💻 HPP
字号:
//*************************************************************************//  MODULE : Process File System Support Object.                          *//  AUTHOR : Ron Chernich                                                 *//  PURPOSE: Encapsulates how Exec will interface to the file system,     *//           presenting a FS wrapper api which is file system independent *//  HISTORY:                                                              *//   30-AUG-94  First MS (Visual C++ 1.5) implementation.                 *//*************************************************************************#ifndef __FS_IFACE__  #define __FS_IFACE__    #include "cpmfs.hpp"      ///////////////////  // First, an arbitrary fixed limit on files per process and state  // values associated with each valid file instance..  //  #define MAX_FILES     8  #define FS_EOFmark    0x1a    /////////////////  // This class, which facilitates "high level" disk services on behalf  // of a single process through the "low level" file system primitives,  // runs as a "Finite State Automaton/Machine".  The following enumeration  // defines the states; the comments give the events causing the state  // change.  See the Tech Docs for an actual Finite State Diagram...  //  enum FSM {    FSM_Zombie,		// the living dead state (can't happen)    FSM_Assigned,       // Assign ok    FSM_Opening,        // Open message sent    FSM_Creating,       // Creat message sent                                   FSM_DiskFull,       // Creat failed due full disk or directory    FSM_BufferMT,       // Open/Creat 0k received, or read/write emptied buf    FSM_Reading,        // Read message posted    FSM_DataAvailable,  // Read ok received, data in buffer    FSM_BuffAvailable,  // Write accepted and buffered for later    FSM_Writing,        // Write message posted to flush buffer    FSM_Closing,        // Close issued when nWriteCnt > 0    FSM_Closed,         // Close (buffer flush and dir update) received    FSM_EOF,            // after "Reading" when at End Of File    FSM_DiskError,      // from reading/writing/closing - fatal error    FSM_Flushing,       // write forced by close    FSM_Deleting,       // "real" delete message posted from "Assigned"    FSM_NotExist,       // delete fails from "deleting" (Purging ignores)    FSM_Exit            // all over (trailing comma ok with new ANSI std)  };    ////////////  // This structure extends the basic File Control Block. Each file  // to be maintained on behalf of the process requires one of these..  //  typedef struct xfcb_tag {    FCB    Fcb;                 // FS File Control Block struct    FSM    mState;              // current FSM state for this file    UINT16 ndx;                 // deblocking I/O buffer index    UINT16 nErrCnt;             // count of hard errors (one usually aborts)    UINT16 nReadCnt;            // total file reads,    UINT16 nWriteCnt;           // and writes (flush on close when non-zero)    char   *pszTemp;            // buffer write overflow holder  } XFCB, *PXFCB;    /////////////  // Everything a PID needs to know about the interface to any file system..  //  class FsIface {  private:    Knl    *pTx;                 // copy of Exec Message dispatcher    UINT16  uID;                 // copy of Exec unique identifier    UINT16  uMagic;              // "magic" number to offset array base    PXFCB   pXfcb[MAX_FILES];    // files per process    BOOL    ExpandName (char*, char*, UINT16); // expand name with wild card    inline  UINT16 Idx (HANDLE h) { return (UINT16)h - uMagic; }  public:    FsIface (UINT16, Knl*);   ~FsIface (void);    UINT16 IsEof (HANDLE);                       // check for End of File    UINT16 Open (HANDLE, UINT16 = FS_Ok);        // open existing file    UINT16 Close (HANDLE, UINT16 = FS_Ok);       // close and maybe flush    UINT16 Delete (HANDLE, UINT16 = FS_Ok);      // delete if exists    UINT16 Creat (HANDLE, UINT16 = FS_Ok);       // create new    UINT16 CloseAll (UINT16 = FS_Ok);            // close and flush all    UINT16 Read (HANDLE, char&, UINT16 = FS_Ok); // read a char    UINT16 Read (HANDLE, char*, UINT16 = FS_Ok); // read delimited string    UINT16 Write (HANDLE, char, UINT16 = FS_Ok); // write single char    UINT16 Write (HANDLE, char*,UINT16 = FS_Ok); // write null terminated    UINT16 Stat (HANDLE, UINT16 = FS_Ok);        // get (open) file size    UINT16 FindFirst (HANDLE, UINT16 = FS_Ok);   // locate first by template    UINT16 FindNext (HANDLE, UINT16 = FS_Ok);    // repeat for next match    UINT16 Allocate (HANDLE&, char*);            // ask for a new XFCB  };#endif/********************************** eof **********************************/

⌨️ 快捷键说明

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