aboutsummaryrefslogtreecommitdiff
path: root/src/fetch_src.cc
blob: 626e7982c33640a64d19a65ae2999ed90c24cbba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdlib.h>
#include <iostream>
#include "fetch_src.hh"
#include "fetch_git.hh"

void fetch_src(Pkg pkg) {
  std::cout << print_pkgit << "target source directory: " << pkg.src << std::endl;
  if (std::filesystem::exists(pkg.src)) {
    std::cout << print_pkgit << pkg.src << " already exists. deleting..." << std::endl;
    std::filesystem::remove_all(pkg.src);
  }
  if (pkg.url == "") {
    std::cout << print_pkgit << "creating directory " << pkg.src << "..." << std::endl;
    std::filesystem::create_directories(pkg.src);
    return;
  }
  else if (fetch_git(pkg) == 0) {
    std::cout << print_pkgit << "cloned into " << pkg.src << "..." << std::endl;
    return;
  }
  else {
    std::cout << print_error << "no fetch methods worked." << std::endl;
    exit(EXIT_FAILURE);
  }
}