Share this page

# mkdir

File Manipulation Functions

Creates a directory using the given path name.

    int mkdir( const char *path);

path | The path and directory name to create.

For mkdir details, refer to your C language documentation.

## Return Values

This function returns zero upon success and (-1) for failure.

## Example

The following example uses mkdir to create a new directory, xyz. It then moves to the new directory.

Copy code

        #ifdef unix
            char new_dir[] = "/tmp/xyz";
        #else
            char new_dir[] = "C:\\xyz";
        #endif
        // Create a directory under root called xyz and make it the current dir
        if (mkdir(new_dir)) {
            lr_output_message ("Create directory %s failed", new_dir);
            return -1;
        }
        else
             lr_output_message ("Created new directory %s", new_dir);
        if (chdir(new_dir)) {
            lr_output_message ("Unable to change to dir %s", new_dir);
            return -1;
         }
        else
            lr_output_message ("Changed to new dir %s", new_dir);
        return 0;

    Example: Output:
    Action.c(16): Created new directory C:\xyz
    Action.c(24): Changed to new dir C:\xyz

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: