View | Details | Raw Unified | Return to bug 162050
Collapse All | Expand All

(-)src/lv.c (-3 / +23 lines)
Lines 2-7 Link Here
2
 * lv.c
2
 * lv.c
3
 *
3
 *
4
 * All rights reserved. Copyright (C) 1996 by NARITA Tomio.
4
 * All rights reserved. Copyright (C) 1996 by NARITA Tomio.
5
 * Copyright (C) Oct 27, 2011 Koichiro IWAO. All rights reserved.
5
 * $Id: lv.c,v 1.10 2004/01/05 07:30:15 nrt Exp $
6
 * $Id: lv.c,v 1.10 2004/01/05 07:30:15 nrt Exp $
6
 */
7
 */
7
/*
8
/*
Lines 89-104 Link Here
89
    grep_mode = FALSE;
90
    grep_mode = FALSE;
90
}
91
}
91
92
93
private boolean_t isDirectory(byte **file) {
94
  struct stat buf;
95
  stat((unsigned char *)file, &buf);
96
  if (S_ISDIR(buf.st_mode)) {
97
    fprintf(stderr, "%s is a directory\n", file);
98
    return TRUE;
99
  } else {
100
    return FALSE;
101
  }
102
}
103
92
private boolean_t LvOpen( conf_t *conf )
104
private boolean_t LvOpen( conf_t *conf )
93
{
105
{
106
  boolean_t flagIsDirectory = FALSE;
107
94
  if( NULL != conf->file ){
108
  if( NULL != conf->file ){
109
    if( TRUE == isDirectory( *conf->file ) ){
110
      flagIsDirectory = TRUE;
111
    }
95
    if( NULL == (conf->st = StreamOpen( *conf->file )) ){
112
    if( NULL == (conf->st = StreamOpen( *conf->file )) ){
96
      while( NULL != *(++conf->file) ){
113
      while( NULL != *(++conf->file) ){
97
	if( NULL != (conf->st = StreamOpen( *conf->file )) )
114
	if( NULL != (conf->st = StreamOpen( *conf->file )) ){
98
	  return TRUE;
115
          if( TRUE == isDirectory( *conf->file ) ){
116
            flagIsDirectory = TRUE;
117
	  }
118
	}
99
      }
119
      }
100
      return FALSE;
101
    }
120
    }
121
    return (TRUE == flagIsDirectory ? FALSE : TRUE);
102
  } else {
122
  } else {
103
    conf->st = StreamReconnectStdin();
123
    conf->st = StreamReconnectStdin();
104
  }
124
  }

Return to bug 162050