Module: LinuxStat::NFTW

Defined in:
ext/nftw/nftw.c

Constant Summary collapse

FLAGS =

Constants

flags_hash(nftw)
FTW_ACTIONRETVAL =
INT2FIX(FTW_ACTIONRETVAL)
FTW_CHDIR =
INT2FIX(FTW_CHDIR)
FTW_DEPTH =
INT2FIX(FTW_DEPTH)
FTW_MOUNT =
INT2FIX(FTW_MOUNT)
FTW_PHYS =
INT2FIX(FTW_PHYS)
FTW_CONTINUE =
INT2FIX(FTW_CONTINUE)
FTW_SKIP_SIBLINGS =
INT2FIX(FTW_SKIP_SIBLINGS)
FTW_SKIP_SUBTREE =
INT2FIX(FTW_SKIP_SUBTREE)
FTW_STOP =
INT2FIX(FTW_STOP)
FTW_D =

typeflags

INT2FIX(FTW_D)
FTW_DNR =
INT2FIX(FTW_DNR)
FTW_DP =
INT2FIX(FTW_DP)
FTW_F =
INT2FIX(FTW_F)
FTW_NS =
INT2FIX(FTW_NS)
FTW_SL =
INT2FIX(FTW_SL)
FTW_SLN =
INT2FIX(FTW_SLN)

Class Method Summary collapse

Class Method Details

.count_children(rb_dir, rb_flags) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'ext/nftw/nftw.c', line 144

VALUE getChildrenCount(volatile VALUE obj, volatile VALUE rb_dir, volatile VALUE rb_flags) {
	TOTAL_FILES = 0 ;
	rb_ary_clear(LIST) ;

	int flags = FIX2INT(rb_flags);
	char *dir = StringValuePtr(rb_dir) ;
	VALUE returnValue = rb_hash_new() ;

	if (nftw(dir, countChildren, 20, flags) == -1) {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), ULL2NUM(TOTAL_FILES)) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qtrue) ;
	} else {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), ULL2NUM(TOTAL_FILES)) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qfalse) ;
	}

	return returnValue ;
}

.count_directories(rb_dir) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'ext/nftw/nftw.c', line 177

VALUE getDirectoriesCount(volatile VALUE obj, volatile VALUE rb_dir) {
	TOTAL_FILES = 0 ;

	int flags = FTW_PHYS ;
	#ifdef FTW_CONTINUE
		flags |= FTW_CONTINUE ;
	#endif

	if (nftw(StringValuePtr(rb_dir), countDirectories, 20, flags) == -1)
		return Qnil ;

	return ULL2NUM(--TOTAL_FILES) ;
}

.count_files(rb_dir) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'ext/nftw/nftw.c', line 163

VALUE getFilesCount(volatile VALUE obj, volatile VALUE rb_dir) {
	TOTAL_FILES = 0 ;

	int flags = FTW_PHYS ;
	#ifdef FTW_CONTINUE
		flags |= FTW_CONTINUE ;
	#endif

	if (nftw(StringValuePtr(rb_dir), countFiles, 20, flags) == -1)
		return Qnil ;

	return ULL2NUM(TOTAL_FILES) ;
}

.stat(rb_dir, rb_flags) ⇒ Object

Methods



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'ext/nftw/nftw.c', line 191

VALUE getStat(volatile VALUE obj, volatile VALUE rb_dir, volatile VALUE rb_flags) {
	rb_ary_clear(LIST) ;

	int flags = FIX2INT(rb_flags);
	char *dir = StringValuePtr(rb_dir) ;
	VALUE returnValue = rb_hash_new() ;

	if (nftw(dir, storeInfo, 20, flags) == -1) {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), LIST) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qtrue) ;
	} else {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), LIST) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qfalse) ;
	}

	return returnValue ;
}

.stat_files(rb_dir) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'ext/nftw/nftw.c', line 209

VALUE getFilesStat(volatile VALUE obj, volatile VALUE rb_dir) {
	rb_ary_clear(LIST) ;

	int flags = FTW_PHYS ;
	#ifdef FTW_CONTINUE
		flags |= FTW_CONTINUE ;
	#endif

	char *dir = StringValuePtr(rb_dir) ;
	VALUE returnValue = rb_hash_new() ;

	if (nftw(dir, storeFilesInfo, 20, flags) == -1) {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), LIST) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qtrue) ;
	} else {
		rb_hash_aset(returnValue, ID2SYM(rb_intern("value")), LIST) ;
		rb_hash_aset(returnValue, ID2SYM(rb_intern("error")), Qfalse) ;
	}

	return returnValue ;
}