Category : Files from Magazines
Archive   : CUJ9306.ZIP
Filename : 1106134A

 
Output of file : 1106134A contained in archive : CUJ9306.ZIP
/* ddir.c: Remove directory tree */

#include
#include
#include
#include
#include
#include
#include

/* All POSIX-compliant systems have this one */
#include

/* Borland C also requires this one */
#include

/* This is required to redirect stderr on DOS */
#include "stderr.h"

/* DOS-specific macros - change for other OS */
#define CMD_FORMAT "del *.* <%s > nul"
#define CMD_LEN 17

/* Change this to "/" for UNIX */
char Response_file[L_tmpnam+1] = "\\";

void rd(char *);

main(int argc, char **argv)
{
FILE *f;
char *old_path = getcwd(NULL,FILENAME_MAX);

/* Create response file for DOS del command */
tmpnam(Response_file+1);
assert((f = fopen(Response_file,"w")) != NULL);
fputs("Y\n",f);
fclose(f);

/* Delete the directories */
while (--argc)
rd(*++argv);

/* Clean-up */
remove(Response_file);
chdir(old_path);
free(old_path);
return 0;
}

void rd(char * dir)
{
char sh_cmd[L_tmpnam+CMD_LEN];
DIR *dirp;
struct dirent *entry;
struct stat finfo;

/* Log onto the directory that is to be deleted */
assert(chdir(dir) == 0);
printf("%s:\n",strlwr(dir));

/* Delete all normal files via OS shell */
hide_stderr();
sprintf(sh_cmd,CMD_FORMAT,Response_file);
system(sh_cmd);
restore_stderr();

/* Delete any remaining directory entries */
assert((dirp = opendir(".")) != NULL);
while ((entry = readdir(dirp)) != NULL)
{
if (entry->d_name[0] == '.')
continue;
stat(entry->d_name,&finfo);
if (finfo.st_mode & S_IFDIR)
rd(entry->d_name); /* Subdirectory */
else
{
/* Enable delete of file, then do it */
chmod(entry->d_name,S_IWRITE);
assert(unlink(entry->d_name) == 0);
}
}
closedir(dirp);

/* Remove the directory from its parent */
assert(chdir("..") == 0);
assert(rmdir(dir) == 0);
}




  3 Responses to “Category : Files from Magazines
Archive   : CUJ9306.ZIP
Filename : 1106134A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/