aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2004-10-03 05:18:31 +0000
committerJason Woodward2004-10-03 05:18:31 +0000
commit11825421d33750aa105c91888dde8f88b5e004ce (patch)
tree31ef93dfaf14114eedd96060fba1dd1b18d8753a /src
parentdd2b267293fa1ed9865e6b4f6d3649823748fa4e (diff)
downloadslapt-get-11825421d33750aa105c91888dde8f88b5e004ce.tar.gz
moved clean_pkg_dir() from configuration.[ch] to package.[ch]
Diffstat (limited to 'src')
-rw-r--r--src/configuration.c45
-rw-r--r--src/configuration.h1
-rw-r--r--src/package.c45
-rw-r--r--src/package.h2
4 files changed, 47 insertions, 46 deletions
diff --git a/src/configuration.c b/src/configuration.c
index cc9acee..33c3c57 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -158,51 +158,6 @@ void working_dir_init(const rc_config *global_config){
return;
}
-void clean_pkg_dir(const char *dir_name){
- DIR *dir;
- struct dirent *file;
- struct stat file_stat;
-
- if( (dir = opendir(dir_name)) == NULL ){
- fprintf(stderr,_("Failed to opendir %s\n"),dir_name);
- return;
- }
-
- if( chdir(dir_name) == -1 ){
- fprintf(stderr,_("Failed to chdir: %s\n"),dir_name);
- return;
- }
-
- while( (file = readdir(dir)) ){
-
- /* make sure we don't have . or .. */
- if( (strcmp(file->d_name,"..")) == 0 || (strcmp(file->d_name,".") == 0) )
- continue;
-
- /* setup file_stat struct */
- if( (stat(file->d_name,&file_stat)) == -1)
- continue;
-
- /* if its a directory, recurse */
- if( S_ISDIR(file_stat.st_mode) ){
- clean_pkg_dir(file->d_name);
- if( (chdir("..")) == -1 ){
- fprintf(stderr,_("Failed to chdir: %s\n"),dir_name);
- return;
- }
- continue;
- }
- if( strstr(file->d_name,".tgz") !=NULL ){
- #if DEBUG == 1
- printf(_("unlinking %s\n"),file->d_name);
- #endif
- unlink(file->d_name);
- }
- }
- closedir(dir);
-
-}
-
void free_rc_config(rc_config *global_config){
int i;
diff --git a/src/configuration.h b/src/configuration.h
index 52d8f66..a4e80db 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -53,5 +53,4 @@ typedef struct _configuration rc_config;
rc_config *read_rc_config(const char *file_name);
void working_dir_init(const rc_config *global_config);
-void clean_pkg_dir(const char *dir_name);
void free_rc_config(rc_config *global_config);
diff --git a/src/package.c b/src/package.c
index 281c054..8a10247 100644
--- a/src/package.c
+++ b/src/package.c
@@ -2126,3 +2126,48 @@ void purge_old_cached_pkgs(const char *dir_name){
}
+void clean_pkg_dir(const char *dir_name){
+ DIR *dir;
+ struct dirent *file;
+ struct stat file_stat;
+
+ if( (dir = opendir(dir_name)) == NULL ){
+ fprintf(stderr,_("Failed to opendir %s\n"),dir_name);
+ return;
+ }
+
+ if( chdir(dir_name) == -1 ){
+ fprintf(stderr,_("Failed to chdir: %s\n"),dir_name);
+ return;
+ }
+
+ while( (file = readdir(dir)) ){
+
+ /* make sure we don't have . or .. */
+ if( (strcmp(file->d_name,"..")) == 0 || (strcmp(file->d_name,".") == 0) )
+ continue;
+
+ /* setup file_stat struct */
+ if( (stat(file->d_name,&file_stat)) == -1)
+ continue;
+
+ /* if its a directory, recurse */
+ if( S_ISDIR(file_stat.st_mode) ){
+ clean_pkg_dir(file->d_name);
+ if( (chdir("..")) == -1 ){
+ fprintf(stderr,_("Failed to chdir: %s\n"),dir_name);
+ return;
+ }
+ continue;
+ }
+ if( strstr(file->d_name,".tgz") !=NULL ){
+ #if DEBUG == 1
+ printf(_("unlinking %s\n"),file->d_name);
+ #endif
+ unlink(file->d_name);
+ }
+ }
+ closedir(dir);
+
+}
+
diff --git a/src/package.h b/src/package.h
index d2b4ef6..9f90404 100644
--- a/src/package.h
+++ b/src/package.h
@@ -144,6 +144,8 @@ struct pkg_list *get_pkg_conflicts(struct pkg_list *avail_pkgs,struct pkg_list *
/* return list of packages required by */
struct pkg_list *is_required_by(const rc_config *global_config,struct pkg_list *avail, pkg_info_t *pkg);
+/* empty packages from cache dir */
+void clean_pkg_dir(const char *dir_name);
/* clean out old outdated packages in the cache */
void purge_old_cached_pkgs(const char *dir_name);