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



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'ext/nftw/nftw.c', line 134

VALUE getChildrenCount(VALUE obj, VALUE rb_dir, 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



167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'ext/nftw/nftw.c', line 167

VALUE getDirectoriesCount(VALUE obj, 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



153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'ext/nftw/nftw.c', line 153

VALUE getFilesCount(VALUE obj, 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



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'ext/nftw/nftw.c', line 181

VALUE getStat(VALUE obj, VALUE rb_dir, 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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'ext/nftw/nftw.c', line 199

VALUE getFilesStat(VALUE obj, 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;
}