Re: [Vala] Checking if FileInfo is a directory
- From: JM <interflug1 gmx net>
- To: matthew <matio quickbeam me uk>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Checking if FileInfo is a directory
- Date: Thu, 19 Aug 2010 18:50:10 +0200
Try this:
int line_count(string path, string[] extentions) {
int lines = 0;
try {
File directory = File.new_for_path(path);
var enumerator =
directory.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME + "," +
FILE_ATTRIBUTE_STANDARD_TYPE,
FileQueryInfoFlags.NONE,
null
);
FileInfo file_info;
while ((file_info = enumerator.next_file(null)) != null) {
if(file_info.get_file_type() == FileType.DIRECTORY) {
stdout.printf("%s is a directory\n", file_info.get_name());
}
else {
stdout.printf("%s\n", file_info.get_name());
}
}
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
return 1;
}
return lines;
}
int main (string[] args) {
line_count("./tstt", new string[]{});
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]