Honor temp_dir when creating new files.

For #49.
This commit is contained in:
Pascal Obry
2015-04-15 11:20:42 +02:00
parent 086d6383f6
commit 08ce000401
+20 -1
View File
@@ -276,7 +276,26 @@ static int cfs_mkdir(const char *path, mode_t mode)
static int cfs_create(const char *path, mode_t mode, struct fuse_file_info *info)
{
FILE *temp_file = tmpfile();
FILE *temp_file;
if (*temp_dir)
{
char tmp_path[PATH_MAX];
strncpy(tmp_path, path, PATH_MAX);
char *pch;
while((pch = strchr(tmp_path, '/'))) {
*pch = '.';
}
char file_path[PATH_MAX];
snprintf(file_path, PATH_MAX, "%s/.cloudfuse%ld-%s", temp_dir,
(long)getpid(), tmp_path);
temp_file = fopen(file_path, "w+b");
}
else
temp_file = tmpfile();
openfile *of = (openfile *)malloc(sizeof(openfile));
of->fd = dup(fileno(temp_file));
fclose(temp_file);