summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-01-08 22:28:49 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-01-08 22:28:49 +0100
commit46e39c8e14dc98045107cfb38af8cecb8a4773b0 (patch)
treefc51ea417acab91f22e968f1fe7e5e0eb1a23b56 /apt-pkg/contrib
parent48b78442a60faf567390eab4372fe3e06c183e73 (diff)
* French manpage translation update
* spot & fix various typos in all manpages * German manpage translation update * cmdline/apt-cache.cc: - remove translatable marker from the "%4i %s\n" string * buildlib/po4a_manpage.mak: - instruct debiandoc to build files with utf-8 encoding * buildlib/tools.m4: - fix some warning from the buildtools * apt-pkg/acquire-item.cc: - add configuration PDiffs::Limit-options to not download too many or too big patches (Closes: #554349) * debian/control: - let all packages depend on ${misc:Depends} * share/*-archive.gpg: - remove the horrible outdated files. We already depend on the keyring so we don't need to ship our own version * cmdline/apt-key: - errors out if wget is not installed (Closes: #545754) - add --keyring option as we have now possibly many * methods/gpgv.cc: - pass all keyrings (TrustedParts) to gpgv instead of using only one trusted.gpg keyring (Closes: #304846) * methods/https.cc: - finally merge the rest of the patchset from Arnaud Ebalard with the CRL and Issuers options, thanks! (Closes: #485963)
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/configuration.cc41
-rw-r--r--apt-pkg/contrib/fileutl.cc50
-rw-r--r--apt-pkg/contrib/fileutl.h3
3 files changed, 55 insertions, 39 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 4e8586e83..08faf22b5 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -22,14 +22,8 @@
#include <apti18n.h>
#include <vector>
-#include <algorithm>
#include <fstream>
#include <iostream>
-
-#include <stdio.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
using namespace std;
/*}}}*/
@@ -835,39 +829,8 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
// ReadConfigDir - Read a directory of config files /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ReadConfigDir(Configuration &Conf,const string &Dir,bool AsSectional,
- unsigned Depth)
-{
- DIR *D = opendir(Dir.c_str());
- if (D == 0)
- return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
-
- vector<string> List;
-
- for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
- {
- if (Ent->d_name[0] == '.')
- continue;
-
- // Skip bad file names ala run-parts
- const char *C = Ent->d_name;
- for (; *C != 0; C++)
- if (isalpha(*C) == 0 && isdigit(*C) == 0 && *C != '_' && *C != '-')
- break;
- if (*C != 0)
- continue;
-
- // Make sure it is a file and not something else
- string File = flCombine(Dir,Ent->d_name);
- struct stat St;
- if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
- continue;
-
- List.push_back(File);
- }
- closedir(D);
-
- sort(List.begin(),List.end());
+{
+ vector<string> const List = GetListOfFilesInDir(Dir, "", true);
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 4240d9f49..cce8a4512 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -34,9 +34,11 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
+#include <dirent.h>
#include <signal.h>
#include <errno.h>
#include <set>
+#include <algorithm>
/*}}}*/
using namespace std;
@@ -195,6 +197,54 @@ bool FileExists(string File)
return true;
}
/*}}}*/
+// GetListOfFilesInDir - returns a vector of files in the given dir /*{{{*/
+// ---------------------------------------------------------------------
+/* If an extension is given only files with this extension are included
+ in the returned vector, otherwise every "normal" file is included. */
+std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext,
+ bool const &SortList)
+{
+ std::vector<string> List;
+ DIR *D = opendir(Dir.c_str());
+ if (D == 0)
+ {
+ _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+ return List;
+ }
+
+ for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
+ {
+ if (Ent->d_name[0] == '.')
+ continue;
+
+ if (Ext.empty() == false && flExtension(Ent->d_name) != Ext)
+ continue;
+
+ // Skip bad file names ala run-parts
+ const char *C = Ent->d_name;
+ for (; *C != 0; ++C)
+ if (isalpha(*C) == 0 && isdigit(*C) == 0
+ && *C != '_' && *C != '-' && *C != '.')
+ break;
+
+ if (*C != 0)
+ continue;
+
+ // Make sure it is a file and not something else
+ string const File = flCombine(Dir,Ent->d_name);
+ struct stat St;
+ if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
+ continue;
+
+ List.push_back(File);
+ }
+ closedir(D);
+
+ if (SortList == true)
+ std::sort(List.begin(),List.end());
+ return List;
+}
+ /*}}}*/
// SafeGetCWD - This is a safer getcwd that returns a dynamic string /*{{{*/
// ---------------------------------------------------------------------
/* We return / on failure. */
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 73b5ea3be..2807c29d9 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -23,6 +23,7 @@
#include <string>
+#include <vector>
using std::string;
@@ -81,6 +82,8 @@ bool RunScripts(const char *Cnf);
bool CopyFile(FileFd &From,FileFd &To);
int GetLock(string File,bool Errors = true);
bool FileExists(string File);
+std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext,
+ bool const &SortList);
string SafeGetCWD();
void SetCloseExec(int Fd,bool Close);
void SetNonBlock(int Fd,bool Block);