Hi,
so im Groben vorhast, habe ich wohl verstanden.
Allerdings habe ich nicht verstanden, welcher Pfad wo gespeichert ist, wo das Script abgespeichert ist, welchen Pfad Du anlegen willst und wieso Du nicht die PHP-Funktion mkdir() benutzt?
Weil es in C vielleicht nicht die PHP-Funktion mkdir() gibt ;-) [1]
Aber dafür in POSIX ;-)
ich weiß ja nicht, welches System Du nutzt, aber ein Versuch wäre es wert, nach mkdir() zu suchen.
'man 2 mkdir' sagt hier (Linux. LibC Version 2.2.5):
#include <sys/stat.h>
#include <sys/types.h>
int mkdir(const char *pathname, mode_t mode)
mkdir attempts to create a directory named pathname.
mode specifies the permissions to use. It is modified by
the process's umask in the usual way: the permissions of
the created file are (mode & ~umask).
[...]
RETURN VALUE
mkdir returns zero on success, or -1 if an error occurred
(in which case, errno is set appropriately).
usw.
Beispiel:
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* exit() */
#include <limits.h> /* PATH_MAX */
#include <sys/stat.h> /* für mkdir() */
#include <sys/types.h> /* ditto */
#include <string.h> /* strerror(), strlen() */
#include <errno.h> /* errno */
#ifndef PATH_MAX
#define PATH_MAX 250
#endif
int main(int argc, char **argv){
if(argc < 2){
fprintf(stderr,"Usage: %1.256s directorynames\n", argv[0]);
exit(EXIT_FAILURE);
}
argc--;
while(argc--){
/* Größer PATH_MAX ist jetzt nicht unbedingt
eine wirksame Sicherung ;-) */
if(strlen(argv[argc +1]) > PATH_MAX || mkdir(argv[argc +1],0) != 0){
fprintf(stderr,"mkdir() failed, reason: %1.256s\n",strerror(errno));
exit(EXIT_FAILURE);
}
printf("Verzeichnis %1.256s erfolgreich errichtet\n",argv[argc +1]);
}
exit(EXIT_SUCCESS);
}
so short
Christoph Zurnieden