PDA

View Full Version : Deleting directories in the IFS



Guest.Visitor
01-01-1995, 02:00 AM
I'm trying to remove unwanted directories in the IFS. However, many of them have objects within directories within directories within directories etc ad infinitum. When I try to delete the top-level directory I get CPFA0AC that says that I can't delete a directory while objects exist in it. The message goes on to say that if I am specifying RMVLNK(*YES) on the RMVDIR command (which I am), and it still doesn't work, then "the file system does not support removing existing links". Is there any clever trick to get around this? Or am I stuck with going 8 directories deep and removing objects individually until I eventually re-surface at my top-level again? Ian

GlenKerner
12-07-2000, 07:13 AM
Ian, Is this the Ian Hill formally from Multifoods? I think you are stuck in removing each individually. I've not been able to do it any other way. But maybe somebody else has.

T.Holt
12-07-2000, 08:22 AM
<font color=blue>Is there any clever trick to get around this? Or am I stuck with going 8 directories deep and removing objects individually until I eventually re-surface at my top-level again?</font> You could map it to a network drive & use the DELTREE command from an MS-DOS window.

Guest.Visitor
12-07-2000, 08:31 AM
/* Based on the Opendir sample in the Unix APIs Ref */ /* dxd 1.0 */ #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <stddef.h> /* error constant */ #include <stdlib.h> /* system */ void rmvlnk(char* path, int indent) { int count; char szCmd2048; /* delete the object */ strcpy(szCmd, "RMVLNK OBJLNK('"); strcat(szCmd, path); strcat(szCmd, "') "); if (system(szCmd) == 0 ) { for (count=0; count<indent; count++) printf(" "); printf("%s DELETED
", path); } else { for (count=0; count<indent; count++) printf(" "); printf("%s FAILED - MSG%s
", szCmd, _EXCP_MSGID); } } void traverse(char * fn, int indent) { DIR *dir; struct dirent *entry; int count; char path16384; char szCmd2048; struct stat info; if ((dir = opendir(fn)) == NULL) /* try to open directory */ perror("opendir() error"); else { /* loop thru all objs in dir */ while ((entry = readdir(dir)) != NULL) { if (entry->d_name0 != '.') /* skip current and prev dir */ { strcpy(path, fn); strcat(path, "/"); strcat(path, entry->d_name); /* append new obj to current dir */ /* is this a directory */ if (stat(path, &info) != 0) fprintf(stderr, "stat() error on %s: %s
", path, strerror(errno)); else { if (S_ISDIR(info.st_mode)) /* process subdirectory */ traverse(path, indent + 1); else /* assume file */ rmvlnk(path, indent); } } } closedir(dir); /* delete the dir */ strcpy(szCmd, "RMVDIR DIR('"); strcat(szCmd, fn); strcat(szCmd, "') "); if (system(szCmd) == 0 ) { for (count=0; count<indent; count++) printf(" "); printf("%s DELETED
", fn); } else { for (count=0; count<indent; count++) printf(" "); printf("%s FAILED - MSG%s
", szCmd, _EXCP_MSGID); } } } main(int argc, char **argv) { if (argc != 2) { printf("Usage:
"); printf("Call DelTree <path>
"); printf(" where <path> is the directory delete
"); printf("Example:
"); printf("CALL PGM(DELTREE) PARM('/home/nandelin')
"); return; } traverse(argv1, 0 ); } </p>

Guest.Visitor
12-07-2000, 09:40 AM
"Is this the Ian Hill formally from Multifoods?" The very same. You can get my e-mail address from Kirk & the boys at MFDG.....

GlenKerner
12-07-2000, 09:43 AM
I'll give them a call. I'm not there anymore either.