diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-08-07 21:18:17 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2012-08-07 21:18:17 +0200 |
commit | df9fae0c0ee189519545a0d01488e98c9aac8836 (patch) | |
tree | aeddd88ee55636f94b252d2332328ff2d6ff6c7f | |
parent | 3fed685e79da924dbb7f4de0ffef51027937a0de (diff) | |
download | 0xFFFF-df9fae0c0ee189519545a0d01488e98c9aac8836.tar.bz2 |
fiasco: after fiasco_unpack return back to origin directory
-rw-r--r-- | src/fiasco2.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/fiasco2.c b/src/fiasco2.c index b155ec4..4b743dd 100644 --- a/src/fiasco2.c +++ b/src/fiasco2.c @@ -473,11 +473,23 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) { struct image * image; struct image_list * image_list; uint32_t size; + char cwd[256]; unsigned char buf[4096]; - if ( dir && chdir(dir) < 0 ) { - perror("Cannot chdir"); - return -1; + if ( dir ) { + + memset(cwd, 0, sizeof(cwd)); + + if ( ! getcwd(cwd, sizeof(cwd)) ) { + perror("Cannot getcwd"); + return -1; + } + + if ( chdir(dir) < 0 ) { + perror("Cannot chdir"); + return -1; + } + } image_list = fiasco->first; @@ -556,6 +568,15 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) { } + if ( dir ) { + + if ( chdir(cwd) < 0 ) { + perror("Cannot chdir"); + return -1; + } + + } + return 0; } |