Changeset - c5f38b0ee751
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2010-07-30 22:27:39
ohnobinki@ohnopublishing.net
Fix distren_mkdir_recurse() to actually call mkdir() on the most deeply nested directory.
2 files changed with 25 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -34,6 +34,7 @@
 
#include <archive.h>
 
#include <archive_entry.h>
 

	
 
#include <errno.h>
 
#include <stdio.h>
 
#include <string.h>
 
#include <unistd.h>
 
@@ -306,22 +307,42 @@ void xmlcleanup()
 

	
 

	
 
/** Creates directories recursively */
 
int distren_mkdir_recurse(char *dirname)
 
int distren_mkdir_recurse(const char *dirname)
 
{
 
  size_t counter;
 
  char *nextdir;
 
  int ret;
 

	
 
  nextdir = strdup(dirname);
 
  for(counter = 0; nextdir[counter]; counter ++)
 
  /* skip preficing slashes */
 
  for(counter = 0; nextdir[counter] == '/'; counter ++)
 
    ;
 
  for(; nextdir[counter]; counter ++)
 
    {
 
      /** @TODO OS-portabalize the path-separators */
 
      if(nextdir[counter] == '/')
 
        {
 
          nextdir[counter] = '\0';
 
          mkdir(nextdir, S_IRWXU | S_IRGRP | S_IROTH);
 
          ret = mkdir(nextdir, S_IRWXU | S_IRGRP | S_IROTH);
 
	  if(ret == -1
 
	     && errno != EEXIST)
 
	    {
 
	      perror("mkdir");
 
	      free(nextdir);
 
	      return 1;
 
	    }
 
          nextdir[counter] = '/';
 
        }
 
    }
 
  ret = mkdir(nextdir, S_IRWXU | S_IRGRP | S_IROTH);
 
  if(ret == -1
 
     && errno != EEXIST)
 
    {
 
      perror("mkdir");
 
      free(nextdir);
 
      return 1;
 
    }
 
  free(nextdir);
 

	
 
  return 0;
 
}
src/server/slavefuncs.h
Show inline comments
 
@@ -45,7 +45,7 @@ int conf_replace(char *conffile, char *w
 
int exec_blender(char *input, char *output, int frame);
 
void xmlinit();
 
void xmlcleanup();
 
int distren_mkdir_recurse(char *dirname);
 
int distren_mkdir_recurse(const char *dirname);
 
int job_build_path(char *filename, unsigned int jobnum);
 
int downloadTar(char *url, char *destinationPath);
 
int uploadOutput(char *pathtoOutput, char *urltoOutput, int jobnum, int framenum, int slavekey);
0 comments (0 inline, 0 general)