📄 rtfsapi.h
字号:
/*****************************************************************************
*Filename: RTFSAPI.H - Defines & structures for ms-dos utilities
*
*
* EBS - RTFS (Real Time File Manager)
*
* Copyright Peter Van Oudenaren , 1993
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*
*
*
* Description:
*
*
*
*
****************************************************************************/
#ifndef __RTFSAPI__
#define __RTFSAPI__ 1
#if (!defined(ERTFS_SA))
#include "ostype.h"
#endif
#include "pcconf.h"
typedef int PCFD; /* file desc */
#define ARDONLY 0x1 /* MS-DOS File attributes */
#define AHIDDEN 0x2
#define ASYSTEM 0x4
#define AVOLUME 0x8
#define ADIRENT 0x10
#define ARCHIVE 0x20
#define ANORMAL 0x00
#define CHICAGO_EXT 0x0f /* Chicago extended filename attribute */
/* Date stamping buffer */
typedef struct datestr {
word date;
word time;
} DATESTR;
/* Structure for use by pc_gfirst, pc_gnext */
typedef struct dstat {
char fname[9]; /* Null terminated file and extension */
char fext[4];
#if (VFAT)
byte lfname[FILENAMESIZE]; /* Long file name fro vfat. */
#endif
char filename[15]; /* Null terminated file.ext */
byte fattribute; /* File attributes */
word ftime; /* time & date lastmodified. See date */
word fdate; /* and time handlers for getting info */
dword fsize; /* File size */
/* INTERNAL */
int driveno;
byte pname[9]; /* Pattern. */
byte pext[4];
char path[EMAXPATH];
void *pobj; /* Info for getting at the inode */
void *pmom; /* Info for getting at parent inode */
} DSTAT;
/* Structure for use by pc_stat and pc_fstat */
/* Portions of this structure and the macros were lifted from BSD sources.
See the RTFS ANSI library for BSD terms & conditions */
typedef struct stat
{
int st_dev; /* (drive number, rtfs) */
int st_ino; /* inode number (0) */
dword st_mode; /* (see S_xxxx below) */
int st_nlink; /* (always 1) */
int st_rdev; /* (drive number, rtfs) */
dword st_size; /* file size, in bytes */
DATESTR st_atime; /* last access (all times are the same) */
DATESTR st_mtime; /* last modification */
DATESTR st_ctime; /* last file status change */
long st_blksize; /* optimal blocksize for I/O (cluster size) */
long st_blocks; /* blocks allocated for file */
byte fattribute; /* File attributes - DOS attributes
(non standard but useful) */
} STAT;
/* File seg info structure. An array of these structures is passed
to pc_get_file_extents(). The extents of the file are returned
in this array */
typedef struct fileseginfo {
long block; /* Block number of the current extent */
long nblocks; /* Number of blocks in the extent */
} FILESEGINFO;
/* Free list info structure. An array of these structures is passed
to pc_get_free_list(). The list of free clusters is returned in
this array */
typedef struct freelistinfo {
dword cluster; /* Cluster where the free region starts */
long nclusters; /* Number of free clusters the free segment */
} FREELISTINFO;
/* Values for the st_mode field */
#define S_IFMT 0170000 /* type of file mask */
#define S_IFCHR 0020000 /* character special (unused) */
#define S_IFDIR 0040000 /* directory */
#define S_IFBLK 0060000 /* block special (unused) */
#define S_IFREG 0100000 /* regular */
#define S_IWRITE 0000400 /* Write permitted */
#define S_IREAD 0000200 /* Read permitted. (Always true anyway)*/
#define DEFFILEMODE (S_IREAD|S_IWRITE)
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
/* Error codes */
#define PCERR_FAT_FLUSH 0 /*Cant flush FAT */
#define PCERR_INITMEDI 1 /*Not a DOS disk:pc_dskinit */
#define PCERR_INITDRNO 2 /*Invalid driveno to pc_dskinit */
#define PCERR_INITCORE 3 /*Out of core:pc_dskinit */
#define PCERR_INITDEV 4 /*Can't initialize device:pc_dskinit */
#define PCERR_INITREAD 5 /*Can't read block 0:pc_dskinit */
#define PCERR_BLOCKCLAIM 6 /*PANIC: Buffer Claim */
#define PCERR_BLOCKLOCK 7 /*Warning: freeing a locked buffer */
#define PCERR_REMINODE 8 /*Trying to remove inode with open > 1 */
#define PCERR_FATREAD 9 /* "IO Error While Failed Reading FAT" */
#define PCERR_DROBJALLOC 10 /* "Memory Failure: Out of DROBJ Structures" */
#define PCERR_FINODEALLOC 11 /* "Memory Failure: Out of FINODE Structures" */
/* File creation permissions for open */
/* Note: OCTAL */
#define PS_IWRITE 0000400 /* Write permitted */
#define PS_IREAD 0000200 /* Read permitted. (Always true anyway)*/
/* File access flags */
#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. */
/* Errno values */
#define PEBADF 9 /* Invalid file descriptor*/
#define PENOENT 2 /* File not found or path to file not found*/
#define PEMFILE 24 /* No file descriptors available (too many files open)*/
#define PEEXIST 17 /* Exclusive access requested but file already exists.*/
#define PEACCES 13 /* Attempt to open a read only file or a special (directory)*/
#define PEINVAL 22 /* Seek to negative file pointer attempted.*/
#define PENOSPC 28 /* Write failed. Presumably because of no space*/
#define PESHARE 30 /* Open failed do to sharing */
#define PEDEVICE 31 /* No Valid Disk Present */
#define PEBADDIR 32 /* DELTREE -- Directory structure corrupt */
/* Arguments to SEEK */
#define PSEEK_SET 0 /* offset from begining of file*/
#define PSEEK_CUR 1 /* offset from current file pointer*/
#define PSEEK_END 2 /* offset from end of file*/
/* Arguments to po_extend_file */
#define PC_FIRST_FIT 1
#define PC_BEST_FIT 2
#define PC_WORST_FIT 3
#define PC_FIXED_FIT 4
/* Arguments to critical_error_handler() */
#define CRERR_BAD_FORMAT 1
#define CRERR_NO_CARD 2
#define CRERR_BAD_CARD 3
#define CRERR_CHANGED_CARD 4
#define CRERR_CARD_FAILURE 5
/* Return code from critical_error_handler() */
#define CRITICAL_ERROR_ABORT 1
#define CRITICAL_ERROR_RETRY 2
#define CRITICAL_ERROR_FORMAT 3
#define CRITICAL_ERROR_CLEARECC 4
// File API.C:
BOOLEAN pc_diskflush(char *path);
BOOLEAN pc_mkdir(char *name);
PCFD po_open(char *name, word flag, word mode);
int po_read(PCFD fd, byte *buf, word count);
int po_write(PCFD fd, byte *buf, word count);
long po_lseek(PCFD fd, long offset, int origin);
BOOLEAN po_truncate(PCFD fd, long offset);
BOOLEAN po_flush(PCFD fd);
int po_close(PCFD fd);
BOOLEAN pc_mv(char *name, char *newname);
BOOLEAN pc_unlink(char *name);
BOOLEAN pc_rmdir(char *name);
BOOLEAN pc_deltree(char *name);
long pc_free(char *path, dword *blocks_total, dword *blocks_free);
BOOLEAN pc_gfirst(DSTAT *statobj, char *name);
BOOLEAN pc_gnext(DSTAT *statobj);
void pc_gdone(DSTAT *statobj);
BOOLEAN pc_set_default_drive(char *drive);
BOOLEAN pc_setdfltdrvno(int driveno);
int pc_getdfltdrvno(void);
BOOLEAN pc_set_cwd(char *name);
BOOLEAN pc_isdir(char *path);
BOOLEAN pc_isvol(char *path);
BOOLEAN pc_pwd(char *drive, char *path);
int pc_fstat(PCFD fd, STAT *pstat);
int pc_stat(char *name, STAT *pstat);
BOOLEAN pc_get_attributes(char *path, byte *p_return);
BOOLEAN pc_set_attributes(char *path, byte attributes);
int pc_cluster_size(char *drive);
long po_extend_file(PCFD fd, long n_bytes, long start_cluster, int method);
int pc_get_file_extents(PCFD fd, int infolistsize, FILESEGINFO *plist, BOOLEAN raw);
int pc_raw_read(int driveno, byte *buf, long blockno, int nblocks, BOOLEAN raw_io);
int pc_raw_write(int driveno, byte *buf, long blockno, int nblocks, BOOLEAN raw_io);
int pc_get_free_list(int driveno, int listsize, FREELISTINFO *plist, long threshhold);
int po_chsize(PCFD fd, long offset);
/* UTIL.C */
/* Ansi replacements for functions in util. Take these out if you don't have
ansi */
void copybuff(void *vto, void *vfrom, int size);
void pc_memfill(void *vto, int size, byte c);
#if (defined(ERTFS_SA))
int tc_strcpy(PFCHAR targ, PFCCHAR src);
int tc_strcmp(PFCCHAR s1, PFCCHAR s2);
int tc_strlen(PFCCHAR string);
PFCHAR tc_strcat(PFCHAR targ, PFCCHAR src);
BOOLEAN tc_isdigit(char ch);
int tc_atoi(PFCHAR s);
long tc_atol(PFCHAR s);
void tc_memset(PFBYTE p, byte b, int n);
#endif
#if (NORTELPPC)
BOOLEAN pc_getvolume(char *path, char *buffer);
BOOLEAN pc_writeenable(int slot, BOOLEAN enable_write);
BOOLEAN nortel_check_write(int driveno);
int pcmcia_card_type(int socket);
#endif /* NORTELPPC */
#endif /* __RTFSAPI__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -