#include <Qp0lstdi.h> int QlgRenameUnlink(Qlg_Path_Name_T *old, Qlg_Path_Name_T *new);Service Program Name: QP0LLIB1
The QlgRenameUnlink() function, like the Qp0lRenameUnlink() function, renames a file or a directory specified by old to the name given by new. The difference is that the QlgRenameUnlink() function takes a pointer to a Qlg_Path_Name_T structure, while Qp0lRenameUnlink() takes a pointer to a character string.
Limited information on the old and old parameters is provided here. For more information on these parameters and for a discussion of the authorities required, return values, and related information, see Qp0lRenameUnlink()--Rename File or Directory, Unlink "new" If It Exists.
See Code disclaimer information for information pertaining to code examples.
When you pass two file names to this example, it tries to change the file name from the first name to the second using QlgRenameUnlink().
#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 unlink the 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])); 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])); if (QlgRenameUnlink((Qlg_Path_Name_T *)path_old_ptr, (Qlg_Path_Name_T *)path_new_ptr ) != 0) {perror ( "Could not unlink the file." ); } else {perror ( "File unlinked." ); } } }
Top | UNIX-Type APIs | APIs by category |