SetFileSegments Segmented file support configuration function. Short Name ctSETSEG() Type Low level function Declaration COUNT SetFileSegments(COUNT filno, NINT aseg, NINT tseg, pSEGMDEF pseg) Description SetFileSegments() configures the segments for file filno. aseg specifies the number of active segments, i.e., the segments created immediately. aseg must be at least one and less than or equal to tseg. tseg specifies the total number of segments pointed to by pseg. pseg points to an array of SEGMDEF structures. If the first segment definition pointed to by pseg has a sgname pointing to the empty string, i.e., *sgname == ‘\0’, not sgname == NULL, the sgsize member of the structure becomes the host segment size limit. Only the last segment can have a size limit of zero, which is interpreted as no limit. Additional segments automatically become active as needed, up to the maximum set in tseg. The segments are used in the order defined by the array of SEGMDEF structures pointed to by pseg. The file referenced by filno must be opened in ctEXCLUSIVE mode the first time SetFileSegments() is called. Note that a file which has been created and not yet closed is always in ctEXCLUSIVE mode, regardless of the file mode specified as part of the create call. After the segment definitions have been established by the first call to SetFileSegments(), it is possible to call SetFileSegments() to modify the segment definitions even while the file is being updated. However, it is not possible to change a segment size so that the new size is smaller than the actual physical size of the segment, nor can SetFileSegments() rename a segment that is in use. A segment is in use if data beyond the segment header information has been written to the segment. An active segment is not in use just because it is on disk; data must have been written to it. Therefore, a call to SetFileSegments() can, in real time, change where segments will reside (provided the segment is not already in use) and/or how large they are (provided the new size is not smaller than the current physical size nor is the segmented already completely full). Return
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example SEGMDEF segdef[2] = {
{"d:\\data\\dataseg.2",1024}, /* 1024MB = 1GB size limit */
{"e:\\data\\dataseg.3",0} /* no limit on segment size */
};
if (CreateIFileXtd8( &fil, NULL, NULL, 0L, NULL, NULL, &creblk)) /* pointer to array of XCREblks */ printf("Could not create %s (%d,%d)\n", fil.pfilnam, isam_err, isam_fil);
if (SetFileSegments( fil.tfilno, /* data file number */ 1, /* one active segment (the host segment) */ 2, /* two segment definitions to be passed */ segdef)) /* pointer to the segment definitions */ printf("Could not set file segments (%d,%d)\n", isam_err, isam_fil);
Limitations The fxtsiz member of the XCREblk structure cannot be set higher than the size of the first (host) segment during a file create. This results in SEGM_ERR (674) signifying the need for more segments, which do not exist yet because SetFileSegments() has not yet been called. The file referenced by filno must be opened in ctEXCLUSIVE mode the first time SetFileSegments() is called. See Also GetXtdCreateBlock() |
||||||||||||||||||||||||