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

📄 kfs.doc

📁 KEYED DOS系统版文件处理系统
💻 DOC
📖 第 1 页 / 共 5 页
字号:
                   Contains the name of the database to be created. If 
                   the name has a qualifier, it cannot be PTR. Also, the 
                   base portion of the name cannot be the same as any 
                   other database even if the qualifiers are unique.
         
              KFS_flags
                   Specifies some additional information about the data-
                   base (See the "Special Processing" section for more 
                   discussion of these options). The valid settings for 
                   this field are:
         
                        KFS_Normal_PTR
                             The normal pointer file organization is 
                             used. This results in the initial allocation 
                             of the .PTR file of about 8K but results in 
                             good performance for large databases.
         
                        KFS_Small_PTR
                             The organization of the pointer file will be 
                             changed to save space on the initial allo-
                             cation of the database. This option should 
                             be specified only when the database will be 
                             a small one since larger databases having 
                             this option are slower than for databases 
                             created with KFS_Normal_PTR.     
         
                        KFS_Numeric_Keys
                             The keys in the database will be numeric 
                             keys stored in the Intel long integer for-
                             mat. This option also implies a small 
                             pointer file. 
                                16

         
         
         
         
         





         
                        KFS_Ignore_Case
                             The case of the keys in the database is 
                             ignored. That is, a key of "ABCDE" and "ab-
                             cde" will be treated as the same key.
         
         Example
           /* Create and open a KFS file with alphabetic keys starting */
           /* in the 5th position of the record and 7 bytes long       */ 
           #include <kfs.h>
           KFS_FILEINFO file1;
           char recarea[100];
         
           file1.KFS_flags = KFS_Normal_PTR;
           file1.KFS_keypos = 4;
           file1.KFS_keylen = 7;
           file1.KFS_recsize = 100;
           strcpy(file1.KFS_filename, "C:\\MYDIR\\MYFILE.DAT");
           KFS_Create(&file1);
           if (file1.KFS_rc != KFS_OK)
              printf("Error creating file1\n");
         
         
         Possible KFS_rc Values
              KFS_OK
                   The database was created successfully. 
         
              KFS_Keyed_File_Already_Exists
                   A database with this name already exists.
         
              KFS_Invalid_File_Name 
                   The file name and associated path name is longer than 
                   63 characters. 
         
              KFS_PTR_File_Open_Error
                   An unknown error occurred while attempting to open the 
                   PTR file associated with the database. This error can 
                   occur if there is not enough space on the disk to 
                   allocate the pointer file or if a .PTR file by this 
                   name already exists. 
         
              KFS_Data_File_Open_Error
                   An unknown error occurred while attempting to open the 
                   data file associated with the database.
         















                                17

         
         
         
         
         





         KFS_Delete(fs, area)
              Delete a record from the database. 
         
         
         Parameters
              KFS_FILEINFO *fs
                   A pointer to a KFS file structure.
         
              void *area
                   A pointer to a data area containing the key of the 
                   record to be deleted. This key must be placed at 
                   KFS_keypos of this area before the operation is 
                   issued.
         
         Description
              Delete a record from the database.
         
         
         Required Fields
              KFS_filename
                   Contains the name of an opened database.
         
              area
                   The data area pointed to must contain the key of the 
                   record being deleted beginning in KFS_keypos of the 
                   area. 
         
         
         Example
           /* Add a record to a KFS file                              */
           #include <kfs.h>
           KFS_FILEINFO file1;
           typedef struct m {
              int f1;
              int f2;
              char mykey[7];
              char filler[89];
           } MYSTRUCT;
           MYSTRUCT inarea;
         
           strcpy(file1.KFS_filename, "C:\\MYDIR\\NUMFILE.DAT");
           KFS_Open(&file1);
           memset(&inarea.mykey, ' ', sizeof(inarea.mykey));
           strcpy(&inarea.mykey, "Dkey");
           KFS_Delete(&file1, (char *)&inarea);
           switch (file1.KFS_rc) {
              case KFS_OK:
                 break;
              case KFS_No_Space_On_Disk:
                 printf("Not enough space on disk to add record\n");
                 break;
              default:
                 printf("Error adding record\n");
         
           }
         
         Possible KFS_rc Values -
              KFS_OK
                   The record was deleted successfully.
         
                                18

         
         
         
         
         





              KFS_Key_Not_Found
                   A record with the key specified was not found. The 
                   operation is ignored.
         
              KFS_No_Space_On_Disk
                   There is not enough space on the disk containing the 
                   KFS database to add a record.
         




















































                                19

         
         
         
         
         





         KFS_Open(fs)
              Open an existing database. 
         
         Parameters
              KFS_FILEINFO *fs
                   A pointer to a KFS file structure.
         
         
         Description
              Open an existing database for processing. All databases 
              must be opened before any processing may be done on those 
              databases. 
         
         
         Required Fields
              KFS_filename
                   Contains the name of an existing database to be 
                   opened.
         
         
         Example
           /* Open a KFS file                                          */
           #include <kfs.h>
           KFS_FILEINFO file1;
           char recarea[100];
         
           strcpy(file1.KFS_filename, "C:\\MYDIR\\MYFILE.DAT");
           KFS_Open(&file1);
           if (file1.KFS_rc != KFS_OK)
              printf("Error opening file1\n");
         
         
         Possible KFS_rc Values
              KFS_OK 
                   The database was opened successfully.
         
              KFS_Keyed_File_Does_Not_Exist 
                   The database does not exist.
         
              KFS_Invalid_File_Name
                   The database name and associated path name is longer 
                   than 63 characters. 
         
              KFS_PTR_File_Open_Error
                   An unknown error occurred while attempting to open the 
                   PTR file associated with the database. 
         
              KFS_Data_File_Open_Error
                   An unknown error occurred while attempting to open the 
                   data file associated with the database. 









                                20

         
         
         
         
         





         KFS_Read(fs, area)
              Read a record by key from the database. 
         
         
         Parameters
              KFS_FILEINFO *fs
                   A pointer to a KFS file structure.
         
              void *area
                   A pointer to a data area where the requested record 
                   will be read. The key to be read must be placed at 
                   KFS_keypos of this area before the operation is 
                   issued.
         
         
         Description
              Read a record by key from a database.
         
         
         Required Fields
              KFS_filename
                   Contains the name of an open database.
         
              area
                   The data area pointed to must contain the key of the 
                   record being read beginning at position KFS_keypos. 
         
         
         Example
           /* Read a KFS file by key (keypos=4, keylen=7)              */
           #include <kfs.h>
           KFS_FILEINFO file1;
           char recarea[100];
         
           strcpy(file1.KFS_filename, "C:\\MYDIR\\MYFILE.DAT");
           KFS_Open(&file1);
           if (file1.KFS_rc != KFS_OK)
              printf("Error opening file1\n");
           memset(recarea, ' ', sizeof(recarea));
           /* Note - we kept the terminating NULL as part of the key   */
           strcpy(&recarea[file1.KFS_keypos], "A key");
           KFS_Read(&file1, (void *)recarea);
           if (file1.KFS_rc != KFS_OK)
              printf("Error reading keyed record from file1\n");
         
         
         Possible KFS_rc Values
              KFS_OK
                   The record was read successfully.
         
              KFS_Key_Not_Found
                   A record with the key specified was not found. The 
                   operation is ignored.
         






                                21

         
         
         
         
         





         KFS_ReadFirst(fs, area)
              Read the first record in keyed sequence in the database. 
         
         
         Parameters
              KFS_FILEINFO *fs 
                   A pointer to a KFS file structure.
         
              void *area
                   A pointer to a data area where the first record in the 
                   KFS database will be read.
         
         
         Description
              Read the first record from a database. The record with the 
              lowest key will be read and placed in the data area. 
         
         
         Required Fields
              KFS_filename
                   Contains the name of an open database.
         
         
         Example
           /* Read the all of the records sequentially from a file    */
           #include <kfs.h>
           KFS_FILEINFO file1;
           char recarea[100];
           
           strcpy(file1.KFS_filename, "C:\\MYDIR\\NUMFILE.DAT");
           KFS_Open(&file1);
           if (file1.KFS_rc != KFS_OK)
              printf("Error opening file1\n");
           KFS_ReadFirst(&file1, recarea);
           if (file1.KFS_rc != KFS_OK) printf("Error");
         
         
         Possible KFS_rc Values -
              KFS_OK
                   The record was read successfully.
         
              KFS_Keyed_File_Empty
                   No records were found in the database. The operation 
                   is ignored.















                                22

         
         
         
         
         





         KFS_ReadGen(fs, area, length)
              Read a record using a partial key. 
         
         Parameters
              KFS_FILEINFO *fs
                   A pointer to a KFS file structure.
         
              void *area
                   A pointer to a data area where the requested record 
                   will be read. The partial key to be used must be 
                   placed at KFS_keypos of this area before the operation 
                   is issued.
         
              int length
                   The length of the partial key at KFS_keypos. If the 
                   length specified is 0, the first record in the data-
                   base is read.This length must be less than or equal to 
                   KFS_keylen.
         
         Description
              Read the first record in the database whose first portion 
              matches that of the partial key supplied. If no record 
              matches the partial key, the next logical record in the 
              database is returned.
         
         

⌨️ 快捷键说明

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