Ok got it.
Now with a question for actually creating directories with function mkdir():
When the user enters a mkdir command, I call the mkdir() function:
Code:
void mkdir(Funix *funix, int argCount, char *args[]);
funix is a pointer to the Funix struct, argCount is the number of arguments (including command name itself), and args is an array of strings containing each argument entered. Since I'm on the 2nd page now I'll type again what my Funix and Directory structs looked like:
Funix struct:
Code:
typedef struct
{
Directory *currentDirectory;
int umask;
int time;
} Funix;
Directory struct:
Code:
typedef struct Dir
{
char *name;
int mtime;
struct Dir **subDir;
int numSubDir;
struct Dir *parent;
Permissions *perm;
} Directory;
The program is supposed to create the subdirectory specified in the command by the user UNLESS there are already 3 subdirectories in the current directory (so maximum number of subdirs in each directory is 3). subDirs is supposed to be a "pointer to a dynamically allocated array of pointers to its immediate subdirectories." Right now I haven't done anything with subDirs in my code, but I read the specification again and does that mean subDirs should be a triple pointer (pointer to a dynamically allocated array of pointers) instead of what I have now? If so, how would I create subdirs? I was thinking something like this:
Code:
(*(*funix).currentDirectory).subDirs = (Directory**)malloc(sizeof(Directory));
If so, how would I access each subDir? Just by doing (*(*funix).currentDirectory).subDirs[1], and so on? And I would also be able to acces funix->currentDirectory->subDirs->name and the other members of the Directory struct? Sorry for the long post, there just seems to be so many pointers I'm a little confused just reading the specification. Thanks!