Category : C Source Code
Archive   : NEWTREE.ZIP
Filename : N_DIR.C

 
Output of file : N_DIR.C contained in archive : NEWTREE.ZIP
/* n_dir.c
**
** Copyright (c) 1989, Christopher Laforet
** All Rights Reserved
**
**
** Revision History:
**
** $Header$
**
*/

#define LINT_ARGS

#include
#include
#include
#include
#include "newtree.h"



void get_directories(start, parent)
unsigned char *start;
short parent;
{
short rtn;
short count;
unsigned char search[100];
FILEFINDBUF findbuf;
HDIR hdir;
unsigned short num = 1;

++level;
sprintf(search,"%s%s",start,"*.*");
hdir = _osmode == OS2_MODE ? 0xffff : 0x1;
rtn = DosFindFirst(search,&hdir,0x37,(PFILEFINDBUF)&findbuf,sizeof(FILEFINDBUF),&num,0L);
while (!rtn)
{
if ((findbuf.attrFile & 0x10) && findbuf.achName[0] != '.') /* is subdirectory and not . or ..? */
{
if (cur_nodes >= max_nodes)
{
if (!(nodes = realloc(nodes,(max_nodes += 10) * sizeof(struct node *))))
{
fprintf(stderr,"Out of Memory\n");
exit(-1);
}
}
if (!(nodes[cur_nodes] = calloc(1,sizeof(struct node))))
{
fprintf(stderr,"Out of Memory\n");
exit(-1);
}
strcpy(nodes[cur_nodes]->node_name,findbuf.achName);
nodes[cur_nodes]->node_level = level;
nodes[cur_nodes]->node_parent = parent;
++cur_nodes;
}
else if ((findbuf.attrFile & 0x27) || !findbuf.attrFile) /* files other than subdir and vollabel */
{
++nodes[parent]->node_files;
}
num = 1;
rtn = DosFindNext(hdir,(PFILEFINDBUF)&findbuf,sizeof(FILEFINDBUF),&num);
}
DosFindClose(hdir);
for (count = 0; count < cur_nodes; count++)
{
if (nodes[count]->node_parent == parent) /* recurse the tree */
{
sprintf(search,"%s%s\\",start,nodes[count]->node_name);
get_directories(search, count);
}
}
--level;
}


  3 Responses to “Category : C Source Code
Archive   : NEWTREE.ZIP
Filename : N_DIR.C

  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/