Ignore:
Timestamp:
Nov 18, 2016, 5:31:42 PM (7 years ago)
Author:
Bruno Cornec
Message:

Add function mr_getcwd and use it to allow use o dynamically allocated memory
instead of getcwd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/mondorestore/mondorestore.c

    r3610 r3613  
    1111#include "my-stuff.h"
    1212#include "mr_mem.h"
     13#include "mr_file.h"
    1314#include "../common/mondostructures.h"
    1415#include "../common/libmondo.h"
     
    17461747
    17471748  /** mallco ***/
    1748     char *cwd;
    1749     char *newpath;
     1749    char *old_pwd = NULL;
     1750    char *newpath = NULL;
    17501751    char *tmp = NULL;
    17511752    assert(bkpinfo != NULL);
    17521753
    1753     malloc_string(cwd);
    1754     malloc_string(newpath);
    17551754    log_msg(2, "restore_everything() --- starting");
    17561755    g_current_media_number = 1;
    1757     if (getcwd(cwd, MAX_STR_LEN - 1)) {
    1758         // FIXME
    1759     }
     1756    old_pwd = mr_getcwd();
    17601757    mr_asprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
    17611758    run_program_and_log_output(tmp, FALSE);
     
    17661763        //FIXME
    17671764    }
    1768     if (getcwd(newpath, MAX_STR_LEN - 1)) {
    1769         // FIXME
    1770     }
     1765    newpath = mr_getcwd();
    17711766    log_msg(1, "path is now %s", newpath);
     1767    mr_free(newpath);
     1768
    17721769    log_msg(1, "restoring everything");
    17731770    if (!find_home_of_exe("petris") && !g_text_mode) {
     
    18001797        resB = restore_all_biggiefiles_from_CD(filelist);
    18011798    }
    1802     if (chdir(cwd)) {
     1799    if (chdir(old_pwd)) {
    18031800        //FIXME
    18041801    }
     1802    mr_free(old_pwd);
    18051803    if (resA + resB) {
    18061804        log_to_screen("Errors occurred while data was being restored.");
     
    18131811    kill_petris();
    18141812    log_msg(2, "restore_everything() --- leaving");
    1815     paranoid_free(cwd);
    1816     paranoid_free(newpath);
    18171813    return (resA + resB);
    18181814}
Note: See TracChangeset for help on using the changeset viewer.