浏览代码

src/core/disk_ops: test directory exists

Nathalie Furmento 10 年之前
父节点
当前提交
ae33916a15
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 9 0
      src/core/disk_ops/disk_stdio.c
  2. 8 0
      src/core/disk_ops/unistd/disk_unistd_global.c

+ 9 - 0
src/core/disk_ops/disk_stdio.c

@@ -269,6 +269,15 @@ static void *starpu_stdio_plug(void *parameter, starpu_ssize_t size STARPU_ATTRI
 	char *tmp = malloc(sizeof(char)*(strlen(parameter)+1));
 	STARPU_ASSERT(tmp != NULL);
 	strcpy(tmp,(char *) parameter);
+
+	{
+		struct stat buf;
+		if (!(stat(tmp, &buf) == 0 && S_ISDIR(buf.st_mode)))
+		{
+			_STARPU_ERROR("Directory '%s' does not exist\n", tmp);
+		}
+	}
+
 	return (void *) tmp;
 }
 

+ 8 - 0
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -306,6 +306,14 @@ void *starpu_unistd_global_plug(void *parameter, starpu_ssize_t size STARPU_ATTR
 	STARPU_ASSERT(tmp != NULL);
 	strcpy(tmp,(char *) parameter);
 
+	{
+		struct stat buf;
+		if (!(stat(tmp, &buf) == 0 && S_ISDIR(buf.st_mode)))
+		{
+			_STARPU_ERROR("Directory '%s' does not exist\n", tmp);
+		}
+	}
+
 	return (void *) tmp;
 }