diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 37333bf25ad9a4c538250f5af2f9f1d666362883 (patch) | |
tree | c45e8df5b9efbffe07eb3d9340df7811c7e16943 /lilo-config/common/Files.cc | |
download | tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lilo-config/common/Files.cc')
-rw-r--r-- | lilo-config/common/Files.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lilo-config/common/Files.cc b/lilo-config/common/Files.cc new file mode 100644 index 0000000..19af29d --- /dev/null +++ b/lilo-config/common/Files.cc @@ -0,0 +1,70 @@ +/* Files.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to [email protected] +*/ +#include "Files.h" +#include <glob.h> +#include <sys/stat.h> +#define ISSET(x,y) ((x&y)==y) +StringList &Files::glob(String name, enum Types types, bool dotfiles, bool braces) +{ + glob_t gl; + int flags=0; + StringList *result; + if(dotfiles) + flags |= GLOB_PERIOD; + if(braces) + flags |= GLOB_BRACE; + ::glob(name, flags, NULL, &gl); + if(types==Any) + result=new StringList(gl.gl_pathv, gl.gl_pathc); + else { + struct stat s; + result=new StringList; + for(unsigned int i=0; i<gl.gl_pathc; i++) { + if(!lstat(gl.gl_pathv[i], &s)) { + if(S_ISLNK(s.st_mode) && !ISSET(types,Link)) + continue; + if(S_ISREG(s.st_mode) && !ISSET(types,File)) + continue; + if(S_ISDIR(s.st_mode) && !ISSET(types,Dir)) + continue; + if(S_ISCHR(s.st_mode) && !ISSET(types,CharDevice)) + continue; + if(S_ISBLK(s.st_mode) && !ISSET(types,BlockDevice)) + continue; + if(S_ISFIFO(s.st_mode) && !ISSET(types,Fifo)) + continue; + if(S_ISSOCK(s.st_mode) && !ISSET(types,Socket)) + continue; + result->insert(result->end(), gl.gl_pathv[i]); + } + } + } + globfree(&gl); + return *result; +} |