o. Create Directory - FMKDir()

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 17 - CleO File System >

o. Create Directory - FMKDir()

The FMKDir() command is used to create a new directory.

 

 

Command Prototype

 

int16_t cmd_FMKDir(const char* String);

 

 

Parameters

Description

Path

The location in which the new directory is to be created

 

Code

 

 

void setup() {

 

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

 /* Start building a screen frame */

 CleO.Start();

 

 CleO.StringExt(FONT_MEDIUM, 400, 50, LIGHT_GREEN, TM, 0, 0,

 "Creating TestDir...");

 /* Create directory TestDir in eFlash */

  CleO.FMKDir("@TestDir");

 /* Confirm if the directory is created successfully */

 if(CleO.FStat("@TestDir", NULL) == 1)

 {

   CleO.StringExt(FONT_MEDIUM, 400, 90, LIGHT_GREEN, TM, 0, 0,

   "Create OK");

 }

 else

 {

   CleO.StringExt(FONT_MEDIUM, 400, 90, LIGHT_GREEN, TM, 0, 0,

   "Create FAILED");  

 }

 CleO.StringExt(FONT_MEDIUM, 400, 140, LIGHT_GREEN, TM, 0, 0,

 "Deleting TestDir...");

 /* Delete the directory */

 CleO.FUnLink("@TestDir");

 if(CleO.FStat("@TestDir", NULL) == 0)

 {

   CleO.StringExt(FONT_MEDIUM, 400, 180, LIGHT_GREEN, TM, 0, 0,

   "Delete OK");

 }

 else

 {

   CleO.StringExt(FONT_MEDIUM, 160, 180, LIGHT_GREEN, TM, 0, 0,

   "Delete FAILED");  

 }

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() {}

 

 

Description

 

In the above code snippet, the highlighted section in yellow color shows how the FMKDir() command is used to create a new directory. The FStat() command is used to check whether the directory creation was successful or not. The @ symbol indicates that the directory is created in eFlash.

 

 

Output

 

Here is the output displayed upon executing the code snippet -

 

FMKDir