[pacman-dev] [PATCH] Remove makepath function from frontend
Remove makepath function from pacman frontend, because _alpm_makepath(_mode) is good enough from the libalpm API, so it was duplicated in fact, and this function from the API may be paramiterized with permission rights, while makepath from frontend not. It's a cleaning activity too, at last it wasn't used. ./src/pacman/util.c: - this source code contained the makepath() function definition ./src/pacman/util.h: - this header file contained the makepath() function declaration Signed-off-by: Laszlo Papp <djszapi@archlinux.us> --- src/pacman/util.c | 36 ------------------------------------ src/pacman/util.h | 1 - 2 files changed, 0 insertions(+), 37 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 353aae3..8f6948d 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -99,42 +99,6 @@ int getcols(void) return 0; } -/* does the same thing as 'mkdir -p' */ -int makepath(const char *path) -{ - /* A bit of pointer hell here. Descriptions: - * orig - a copy of path so we can safely butcher it with strsep - * str - the current position in the path string (after the delimiter) - * ptr - the original position of str after calling strsep - * incr - incrementally generated path for use in access/mkdir call - */ - char *orig, *str, *ptr, *incr; - mode_t oldmask = umask(0000); - int ret = 0; - - orig = strdup(path); - incr = calloc(strlen(orig) + 1, sizeof(char)); - str = orig; - while((ptr = strsep(&str, "/"))) { - if(strlen(ptr)) { - /* we have another path component- append the newest component to - * existing string and create one more level of dir structure */ - strcat(incr, "/"); - strcat(incr, ptr); - if(access(incr, F_OK)) { - if(mkdir(incr, 0755)) { - ret = 1; - break; - } - } - } - } - free(orig); - free(incr); - umask(oldmask); - return(ret); -} - /* does the same thing as 'rm -rf' */ int rmrf(const char *path) { diff --git a/src/pacman/util.h b/src/pacman/util.h index a71de2d..7a8c39d 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -41,7 +41,6 @@ int trans_init(pmtransflag_t flags); int trans_release(void); int needs_root(void); int getcols(void); -int makepath(const char *path); int rmrf(const char *path); char *mbasename(const char *path); char *mdirname(const char *path); -- 1.6.4.4
On Sat, Sep 26, 2009 at 12:39 PM, Laszlo Papp <djszapi2@gmail.com> wrote:
Remove makepath function from pacman frontend, because _alpm_makepath(_mode) is good enough from the libalpm API, so it was duplicated in fact, and this function from the API may be paramiterized with permission rights, while makepath from frontend not. It's a cleaning activity too, at last it wasn't used.
./src/pacman/util.c: - this source code contained the makepath() function definition ./src/pacman/util.h: - this header file contained the makepath() function declaration
Whats with the GNU changelog BS? We aren't in the 1987 CVS world anymore; git {show,log,diff} --patch-with-stat can tell me anything you said here. -Dan
On Sat, Sep 26, 2009 at 7:39 PM, Laszlo Papp <djszapi2@gmail.com> wrote:
Remove makepath function from pacman frontend, because _alpm_makepath(_mode) is good enough from the libalpm API, so it was duplicated in fact, and this function from the API may be paramiterized with permission rights, while makepath from frontend not. It's a cleaning activity too, at last it wasn't used.
./src/pacman/util.c: - this source code contained the makepath() function definition ./src/pacman/util.h: - this header file contained the makepath() function declaration
Your commit is confusing. It makes it sound like we could use _alpm_makepath from the frontend which is not true at all. This commit should rather be : remove makepath from the frontend because it is no longer used (the code using it has probably moved to the backend and we have _alpm_makepath there) There are several other functions which are duplicated between backend util.c and frontend util.c , but there is nothing we can do against it.
Remove makepath from the frontend because it is no longer used (the code using it has probably moved to the backend and we have _alpm_makepath there) Signed-off-by: Laszlo Papp <djszapi@archlinux.us> --- src/pacman/util.c | 36 ------------------------------------ src/pacman/util.h | 1 - 2 files changed, 0 insertions(+), 37 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 353aae3..8f6948d 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -99,42 +99,6 @@ int getcols(void) return 0; } -/* does the same thing as 'mkdir -p' */ -int makepath(const char *path) -{ - /* A bit of pointer hell here. Descriptions: - * orig - a copy of path so we can safely butcher it with strsep - * str - the current position in the path string (after the delimiter) - * ptr - the original position of str after calling strsep - * incr - incrementally generated path for use in access/mkdir call - */ - char *orig, *str, *ptr, *incr; - mode_t oldmask = umask(0000); - int ret = 0; - - orig = strdup(path); - incr = calloc(strlen(orig) + 1, sizeof(char)); - str = orig; - while((ptr = strsep(&str, "/"))) { - if(strlen(ptr)) { - /* we have another path component- append the newest component to - * existing string and create one more level of dir structure */ - strcat(incr, "/"); - strcat(incr, ptr); - if(access(incr, F_OK)) { - if(mkdir(incr, 0755)) { - ret = 1; - break; - } - } - } - } - free(orig); - free(incr); - umask(oldmask); - return(ret); -} - /* does the same thing as 'rm -rf' */ int rmrf(const char *path) { diff --git a/src/pacman/util.h b/src/pacman/util.h index a71de2d..7a8c39d 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -41,7 +41,6 @@ int trans_init(pmtransflag_t flags); int trans_release(void); int needs_root(void); int getcols(void); -int makepath(const char *path); int rmrf(const char *path); char *mbasename(const char *path); char *mdirname(const char *path); -- 1.6.4.4
participants (4)
-
Dan McGee
-
Laszlo Papp
-
Laszlo Papp
-
Xavier