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
 
@@ -31,12 +31,13 @@
 
#include <curl/easy.h>
 
#include <curl/types.h>
 

	
 
#include <archive.h>
 
#include <archive_entry.h>
 

	
 
#include <errno.h>
 
#include <stdio.h>
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 
@@ -303,28 +304,48 @@ void xmlcleanup()
 
{
 
  xmlCleanupParser();
 
}
 

	
 

	
 
/** 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;
 
}
 

	
 
/**
 
 @TODO: Use for constructing path to job data locally and/or on data.distren.org
src/server/slavefuncs.h
Show inline comments
 
@@ -42,13 +42,13 @@ int ssh_keygen();
 
int register_user(char *username, char *email);
 
int login_user(char *username);
 
int conf_replace(char *conffile, char *wordtoreplace, char *replacewith);
 
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);
 
int unpackJob(char *outdir, char *pathtoTar);
 
void prepareJobPaths(int jobnum, int framenum, char *outputExt, char *datadir, char **urltoTar,char **pathtoTar,char **pathtoTardir,char **pathtoJob, char **pathtoJobfile,char **urltoJobfile,char **urltoOutput,char **pathtoOutput, char **pathtoRenderOutput, char **pathtoOutdir);
 
int checkUsername(char *username);
0 comments (0 inline, 0 general)