Re: [Vala] Simple filewalker code. Comments?
- From: Raum <raum no-log org>
- To: Al Thomas <astavale yahoo co uk>
- Cc: Vala-list <vala-list gnome org>
- Subject: Re: [Vala] Simple filewalker code. Comments?
- Date: Wed, 05 Aug 2015 09:19:16 +0200
Hello
I've tried to code something similar
https://github.com/Raumy/check_fs
(It uses md5 hash to check changed files on filesystems)
I should write a makefile and more comments ^_^ (main class name ils testapp... So you should consider this
ils not finished :-) )
You should have a look to check.vala.
Regards
Le 28 juil. 2015 12:55, Al Thomas <astavale yahoo co uk> a écrit :
From: Charles Hixson <charleshixsn earthl
ink.net> > > Sent: Tuesday, 28 July 2015, 1:40 > > Subject: Re: [Vala] Simple filewalker code. Comments? > >
Well, part of what I was looking for was stylistic pointers. > > The Wiki Vala hacking page has a style
guide: > https://wiki.gnome.org/Projects/Vala/Hacking#Coding_Style > and Elementary OS write their apps in
Vala and they seem > to be using similar: > https://elementary.io/docs/code/reference#code-style > Although
Yorba take a different approach: > https://wiki.gnome.org/Apps/Geary/CodingConventions > > That's code
formatting style, but also Vala is seen > generally as an object oriented language so you want > to be
thinking about classes and interfaces. Starting to > get an understanding of design patterns by the so-called
Gang of Four and also the SOLID principles helped me. > > > > This is > the first thing I've written in
vala. Partially, the find command is > > less than optimal because I want to include the code within another
program. > > I use find and it took a while for me to get to grips with it > so I thought I would share
a tip based on what I use. > > > > Many languages include a simple filewalking approach, and I > > was
somewhat surprised that I couldn't find one within vala, so > > partially I was looking for a pointer to a
library that I had overlooked. > > > That's interesting, for low level stuff GLib is often the firstplace to
look. The best I could find was this StackOverflow answer >
http://stackoverflow.com/questions/2217519/how-to-walk-a-directory-in-c > One answer pointed to
GFileEnumerator. Code examples on Valadoc: > http://valadoc.org/#!api=gio-2.0/GLib.FileEnumerator > but not
recursive from what I can see. > > > > > And partially I was looking for pointers as to where the community >
recommended that beginners post code and look for tips. > > > > I haven't been really pleased by the
documentation of vala that I could > > find, so I was hoping that there was someplace better than the mailing
list...and a bit over 24 hours for the first response isn't > > encouraging. OTOH, the civil response
*is* encouraging. ValaDoc is > > greatly improved over the last time I investigated vala, but many things >
still seem to assume that you are coming from a background of C > > coding...and that you remember the C
libraries. My most recent > > background is Python and D, so I'm often left in confusion until I dig > >
back deeper...which slows everything down. > > > You could try StackOverflow: >
http://stackoverflow.com/questions/tagged/vala > > One of Vala's key points is its strong compatibility >
with C. This enables a lot of libraries to be used in > a modern object oriented way without having to
rewrite > the libraries. This does mean though you may have to start > a search with how something is done in
C, often GLib, > and then see if their is a Vala translation. > > > Being able to recognise some basic C
interfaces has a > lot less cognitive load that trying to write good, > scalable code in C. > > As to
response times that is a function of the number > of people you are addressing and whether your question >
piques their interest. The larger the community the more > chance of getting someone's interest and they will
then > take the time to write a response. Vala certainly has a > smaller community than Python. > > > > > > >
On 07/27/2015 12:57 PM, Al Thomas wrote: > >>> From: Charles Hixson > >> > >>> 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 > >> _______________________________________________ > >> vala-list
mailing list > >> vala-list gnome org > >> https://mail.gnome.org/mailman/listinfo/vala-list > >> > > >
_______________________________________________ > vala-list mailing list > vala-list gnome org >
https://mail.gnome.org/mailman/listinfo/vala-list
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]