How about this (forgive the non-excellent indenting):

Daniel Dilts wrote:
> int setupDirectoryPad(WINDOW ** pad, const char * dirName) {
> DIR * dir = NULL;
> struct dirent * entry = NULL;
> size_t width = 0;
> size_t height = 0;
> pad = NULL;
>
> if (NULL == (dir = opendir(dirName))) {
> perror("Failed to open directory");
> return errno;
> }
> while ((entry = readdir(dir))) {
> size_t temp = strlen(entry->d_name);
> if (temp > width)
> width = temp;
> ++height;
> }
> if (errno) {
> perror("Error iterating directory");
> return errno;
> }
> rewinddir(dir);
> if (NULL == (pad = newpad())) {
> perror("Error creating directory pad");
> return errno;
> }
> while ((entry = readdir(dir))) { // What's this? Empty loop body?
> }
> if (errno != 0) {
> perror("Error iterating directory");
> return errno;
> }
>
> if (0 != closedir(dir)) {
> perror("Failed to close directory");
> return errno;
>                 }
> return 0;
> }
> ------------------------------------------------------------------------
>
> --------------------
> BYU Unix Users Group 
> http://uug.byu.edu/ 
>
> The opinions expressed in this message are the responsibility of their
> author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
> ___________________________________________________________________
> List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to