From 444ccb0a7c5f88f408bee91db052d00794791ccc Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 22 Jan 2020 01:37:38 -0500 Subject: Groundhog day 2 --- src/manifest.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/manifest.c') diff --git a/src/manifest.c b/src/manifest.c index 5ed3bab..c401cb2 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -14,6 +14,7 @@ Manifest *manifest_from(const char *package_dir) { FSTree *fsdata = NULL; fsdata = fstree(package_dir); + Manifest *info = (Manifest *)calloc(1, sizeof(Manifest)); info->records = fsdata->files_length; info->packages = (ManifestPackage **) calloc(info->records + 1, sizeof(ManifestPackage *)); @@ -98,13 +99,25 @@ void manifest_free(Manifest *info) { /** * Write a `Manifest` to the configuration directory * @param info + * @param outfile * @return */ -int manifest_write(Manifest *info) { +int manifest_write(Manifest *info, const char *outfile) { char *reqs = NULL; char path[PATH_MAX]; memset(path, '\0', sizeof(path)); - strcpy(path, SPM_GLOBAL.package_manifest); + + if (outfile == NULL) { + strcpy(path, SPM_GLOBAL.package_manifest); + } + else { + strcpy(path, outfile); + } + + if (endswith(path, SPM_MANIFEST_FILENAME) != 0) { + strcat(path, DIRSEPS); + strcat(path, SPM_MANIFEST_FILENAME); + } FILE *fp = fopen(path, "w+"); #ifdef _DEBUG -- cgit