#include <Qp0lstdi.h> int QlgRenameKeep(Qlg_Path_Name_T *old, Qlg_Path_Name_T *new);Service Program Name: QP0LLIB1
The QlgRenameKeep() function, like the Qp0lRenameKeep() function, renames a file or a directory specified by old to the name given by new. The difference is that the QlgRenameKeep() function takes pointers to Qlg_Path_Name_T structures, while Qp0lRenameKeep() takes pointers to character strings.
Limited information on the old and new parameters is provided here. For more information on these parameters and for a discussion of the authorities required, return values, and related information, see Qp0lRenameKeep()--Rename File or Directory, Keep "new" If It Exists.
See Code disclaimer information for information pertaining to code examples.
When you pass two file names to this example, it changes the first file name to the second file name using QlgRenameKeep().
#include <Qp0lstdi.h> #include <stdio.h> int main(int argc, char **argv) { if ( argc != 3 ) { printf( "Usage: %s old_fn new_fn\n", argv[0]); perror ( "Could not rename file" ); } else { const char US_const[3]= "US"; const char Language_const[4]="ENU"; typedef struct pnstruct { Qlg_Path_Name_T qlg_struct; /*** EXTRA STORAGE MAY BE NEEDED ***/ char pn[1025]; /* This size must be >= the path */ /* name length or a pointer to */ /* the path name. */ }; struct pnstruct path_old; struct pnstruct path_new; struct pnstruct *path_old_ptr; struct pnstruct *path_new_ptr; memset((void*)&path_old, 0x00, sizeof(struct pnstruct)); path_old_ptr = &path_old; path_old.qlg_struct.CCSID = 37; memcpy(path_old.qlg_struct.Country_ID,US_const,2); memcpy(path_old.qlg_struct.Language_ID,Language_const,3);; path_old.qlg_struct.Path_Type = 0; path_old.qlg_struct.Path_Length = strlen(argv[1]); path_old.qlg_struct.Path_Name_Delimiter[0] = '/'; memcpy(path_old.pn,argv[1],sizeof(argv[1])-1); memset((void*)&path_new, 0x00, sizeof(struct pnstruct)); path_new_ptr = &path_new; path_new.qlg_struct.CCSID = 37; memcpy(path_new.qlg_struct.Country_ID,US_const,2); memcpy(path_new.qlg_struct.Language_ID,Language_const,3);; path_new.qlg_struct.Path_Type = 0; path_new.qlg_struct.Path_Length = strlen(argv[2]); path_new.qlg_struct.Path_Name_Delimiter[0] = '/'; memcpy(path_new.pn,argv[2],sizeof(argv[2])-1); if (QlgRenameKeep((Qlg_Path_Name_T *)path_old_ptr, (Qlg_Path_Name_T *)path_new_ptr ) != 0) {perror ( "Could not rename file." ); } else {perror ( "File renamed." ); } } }
Top | UNIX-Type APIs | APIs by category |