Bladeren bron

Make sure _starpu_mkpath returns the proper error

Samuel Thibault 13 jaren geleden
bovenliggende
commit
7568d78458
1 gewijzigde bestanden met toevoegingen van 5 en 1 verwijderingen
  1. 5 1
      src/common/utils.c

+ 5 - 1
src/common/utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -19,6 +19,7 @@
 #include <common/config.h>
 #include <common/utils.h>
 #include <libgen.h>
+#include <errno.h>
 
 #ifdef __MINGW32__
 #include <io.h>
@@ -30,6 +31,7 @@
 
 int _starpu_mkpath(const char *s, mode_t mode)
 {
+	int olderrno;
 	char *q, *r = NULL, *path = NULL, *up = NULL;
 	int rv;
 
@@ -63,11 +65,13 @@ int _starpu_mkpath(const char *s, mode_t mode)
 		rv = 0;
 
 out:
+	olderrno = errno;
 	if (up)
 		free(up);
 
 	free(q);
 	free(path);
+	errno = olderrno;
 	return rv;
 }