[Midnightbsd-cvs] src [6610] trunk/lib/libmport/fetch.c: try to create the downloads directory if it does not exist.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Mar 1 13:47:36 EST 2014
Revision: 6610
http://svnweb.midnightbsd.org/src/?rev=6610
Author: laffer1
Date: 2014-03-01 13:47:36 -0500 (Sat, 01 Mar 2014)
Log Message:
-----------
try to create the downloads directory if it does not exist.
Modified Paths:
--------------
trunk/lib/libmport/fetch.c
Modified: trunk/lib/libmport/fetch.c
===================================================================
--- trunk/lib/libmport/fetch.c 2014-03-01 18:32:34 UTC (rev 6609)
+++ trunk/lib/libmport/fetch.c 2014-03-01 18:47:36 UTC (rev 6610)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/lib/libmport/fetch.c,v 1.12 2013/03/03 00:29:51 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
#include "mport.h"
#include "mport_private.h"
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h>
+#include <sys/stat.h>
#include <fetch.h>
#include <string.h>
#include <errno.h>
@@ -129,11 +130,18 @@
char *url;
char *dest;
int mirrorCount = 0;
+ struct stat sb;
MPORT_CHECK_FOR_INDEX(mport, "mport_fetch_bundle()");
if (mport_index_get_mirror_list(mport, &mirrors, &mirrorCount) != MPORT_OK)
RETURN_CURRENT_ERROR;
+
+ if (stat(MPORT_FETCH_STAGING_DIR, &sb) != 0 || ! S_ISDIR(sb.st_mode)) {
+ if (mkdir(MPORT_FETCH_STAGING_DIR, S_IRWXU | S_IRWXG)) {
+ RETURN_CURRENT_ERROR;
+ }
+ }
asprintf(&dest, "%s/%s", MPORT_FETCH_STAGING_DIR, filename);
More information about the Midnightbsd-cvs
mailing list