int fs_mkdir(const char *path)
Creates the directory represented by the specified path.
Argument | Description |
---|---|
path | The name of the directory to create |
All intermediate directories must already exist. The specified path must start with a ‘/’ character.
#include "fs/fs.h"
This example demonstrates creating a series of nested directories.
int create_path(void) { int rc; rc = fs_mkdir("/data"); if (rc != 0) goto err; rc = fs_mkdir("/data/logs"); if (rc != 0) goto err; rc = fs_mkdir("/data/logs/temperature"); if (rc != 0) goto err; rc = fs_mkdir("/data/logs/temperature/current"); if (rc != 0) goto err; return 0; err: /* Clean up the incomplete directory tree, if any. */ fs_unlink("/data"); return -1; }