I'd like to copy one directory to another, including subdirectories. Each file that is copied over needs to have its own thread and each following thread must wait for the previous one to finish and exit before being created.

The directory names are passed in *arg separated by a null char.

This is what I have so far...

#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>

void *copydirectory(void *arg);
void *copyfilepass(void *arg);

// Copy Directory function:
void *copydirectory (void *arg)
	int error;
        int fd;
	pthread_t tid;

	/* Version 1:
	 *	Directory names passed in arg, seperated by null char
	 *	Assume both directories exist
	 *	Each file copied, create a thread to run copyfilepass
	// Assuming Directories exist!
	// Create thread to copy:
	if (error = pthread_create(&tid, NULL, copyfilepass, &fd))
           fprintf(stderr, "Failed to create thread: %s\n", strerror(error));
           fprintf("Thread created\n");

copyfilepass will receive the directory name in arg, the code for copyfilepass is:

#include <unistd.h>
#include "restart.h"

void *copyfilepass(void *arg)
  int *argint;

  argint = (int *)arg;
  argint[2] = copyfile(argint[0], argint[1]);
  return argint + 2;

I think where I'm getting confused is the using of file descriptors. I want to copy from Directory One to Directory Two, but it looks like it's becoming an integer?
If anyone could explain this to me or point me in the right direction it would be muchly appreciated.'



commented: Patience! Little grasshopper. -2

#1) Do NOT Bump on these forums. It's rude. When someone that can help sees your post, they will answer.
#2) There is no sense in making threads if only one thread at a time can be created. That defeats the purpose of threads.
#3) A void function cannot return a value.

#1) Swamped post can't be seen by anyone.
#2) I meant executed, multiple threads are set up, but the next one waits for the previous to finish before starting.
#3) A void pointer function can return.

Why are you just passing a void pointer. Why cant you pass the file pointers to the filecopy function ?