GetCtTempFileName Create a file name that is guaranteed to be unique. Can also specify the path for the creation of temporary files. Short Name TMPNAME() Type Low-level function Declaration COUNT GetCtTempFileName(pVOID bufptr, VRLEN bufsiz) Description GetCtTempFileName() by default returns a unique file name in the parameter bufptr. Set bufsiz to the length of the buffer at bufptr, minimum 10 bytes. Three c-tree configuration settings influence how GetCtTempFileName() functions:
The usage of this function varies by c-tree model and how you configure these three c-tree operational values. Standalone Usage To specify a directory name where temporary files are to reside in the standalone model set the global variable, ct_tmppth, to the path desired. Previously, the user profile mask, USERPRF_PTHTMP, was documented for use in the InitCTreeXtd() call. This use of USERPRF_PTHTMP in standalone mode should be considered legacy support. Setting the path with ct_tmppth is the FairCom recommended approach in standalone mode. Client Server Usage The client-server model becomes more complicated as there are two values to consider. The c-tree Server allows specifying a directory name with the TMPNAME_PATH server configuration keyword. In addition, the user profile mask, USERPRF_PTHTMP, will change the behavior of the GetCtTempFileName() function to allow setting the temp path directory location. In the client-server model, the user profile mask takes precedence over the TMPNAME_PATH server configuration setting. Together, the combination of these two settings determine the action taken by the c-tree Server. The following table summarizes the behavior of GetCtTempFileName(): Table 6-5:
Return
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example Standalone Usage #define MAX_SIZE 255 TEXT temp_path[MAX_NAME] = "/usr/fairtemp/"; pTEXT path_buffer;
12, /* files */ 8, /* # 128 bytes sectors */ 32, /* data cache pages */ 0, NULL,NULL,NULL)) {
printf("\nCould not initialize c-tree Plus\n");
exit(2); }
if (!(ct_tmppth = mballc(1, MAX_SIZE))) printf("Error: Failed to allocate %d bytes for temp path buffer\n",
MAX_SIZE);
if (!(path_buffer = mballc(1, MAX_SIZE))) printf("Error: Failed to allocate %d bytes for temp path buffer\n",
MAX_SIZE);
strncpy(ct_tmppth, temp_path, MAX_SIZE);
if(GetCtTempFileName(path_buffer,200L)) {
printf("\nError on GetCtTempFileName, uerr_cod =%d", uerr_cod);
exit(2); }
if (ct_tmppth) {
mbfree(ct_tmppth); ct_tmppth = NULL; } if (path_buffer) {
mbfree(path_buffer); path_buffer = NULL; }
Client Server Usage with USERPRF_PTHTMP #define MAX_SIZE 255 TEXT temp_path[MAX_NAME] = "/usr/fairtemp/"; pTEXT path_buffer;
12, /* files */ 8, /* # 128 bytes sectors */ 32, /* data cache pages */ USRPRF_PTHTMP, /* GetCtTempFileName sets path */ “ADMIN”,”ADMIN”,”FAIRCOMS”)) {
printf("\nCould not initialize c-tree Plus\n");
exit(2); }
if (!(path_buffer = mballc(1, MAX_SIZE))) printf("Error: Failed to allocate %d bytes for temp path buffer\n",
MAX_SIZE);
strncpy(path_buffer, temp_path, MAX_SIZE);
if(GetCtTempFileName(path_buffer, MAX_SIZE)) {
printf("\nError on GetCtTempFileName, uerr_cod =%d", uerr_cod);
exit(2); }
if (path_buffer) {
mbfree(path_buffer); path_buffer = NULL; }
Limitations If a client process on a heterogeneous network sends a GetCtTempFileName() path with an improper directory separator, GetCtTempFileName() returns an error, since the name will not be well defined, instead of automatically changing the separators to match the Server conventions. See also TMPNAME_PATH configuration keyword in the c-tree Server Administrator’s Guide. InitCTreeXtd() |
|||||||||||||||||||||||||||||||||