🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #135

Better way to count files in dirs

#135
From: Skydive!
Date: Mon, 27 Jul 1992 15:42
13 lines
913 bytes
Hello,

I'm modifying some code that I've written in C previously and would like to try
to improve on it.  Right now, in order to determine the number of files
in a directory I am doing a system call "ls -1 | wc -l > tmp" and then opening
the file and fscanf the number.  Obviously this is a very ugly way to do
this and I would like to improve it.

Are there some functions in <dirents> library that I am missing?

Thanks.

bgolden@ncsa.uiuc.edu
Technical Details
Message-ID: <Bs20zI.EoI@news.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!bjg28027

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!bjg28027
From: bjg28027@uxa.cso.uiuc.edu (Skydive!)
Subject: Better way to count files in dirs
Message-ID: <Bs20zI.EoI@news.cso.uiuc.edu>
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Organization: University of Illinois at Urbana
Date: Mon, 27 Jul 1992 15:42:51 GMT
Lines: 14