Re: [Vala] Simple filewalker code. Comments?
- From: Al Thomas <astavale yahoo co uk>
- To: "vala-list gnome org" <vala-list gnome org>
- Subject: Re: [Vala] Simple filewalker code. Comments?
- Date: Mon, 27 Jul 2015 19:57:33 +0000 (UTC)
From: Charles Hixson <charleshixsn earthlink net>
Sent: Sunday, 26 July 2015, 21:09
Subject: [Vala] Simple filewalker code. Comments?
T his is working filewalker code, but I'm hoping someone will tell me if
this is the correct approach.
"correctness" depends on your criteria. You say it works so it is correct.
If on the other hand you want to be productive. Why reinvent the wheel?
Why not just use something like the 'find' command line tool, e.g.
find ./ -type d -exec du --human-readable '{}' \;
will apply the disk usage command to each file in the current directory.
It is a trivial example that just shows how much space each file takes up.
If you want to create a program with a bit more flexibility. Create a
list of file paths in the first step. Then apply a filter function
to each path, so you would use this to remove directories and then
another filter function to remove symlinks, as per your current program.
This allows you to add other filters later.
Once you have a good list iterate over it and call your function, or functions
if you add more in future, with the file path as the parameter.
For a list exmaple see:
https://wiki.gnome.org/Projects/Vala/GeeSamples
All the best with it,
Al
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]