Syntax
int f_getcwd(
char *buff,
unsigned int len
);
Parameters
- buff
- [out] A pointer to the buffer that stores the path of the current working directory.
- len
- [in] The number of bytes of the buffer pointed by buff.
Return value
Returns 0 if the function succeeds, non-zero value otherwise.Remarks
Stores the path of the current working directory in the buffer pointed by buff. However, if the length of the path string exceeds len, non-zero value is returned.Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Sample
#include <stdio.h>
#include "lib.h"
void main(void)
{
char buf[MAX_PATH];
f_getcwd(buf, sizeof(buf));
printf("%s\n",buf); // "1:/"
f_mkdir("1:/DIR1"); // absolute path: Create "1:/DIR1"
f_mkdir("1:/DIR1/DIR2"); // absolute path: Create "1:/DIR1/DIR2"
f_chdir("1:/DIR1/DIR2"); // absolute path: Change CWD to "1:/DIR1/DIR2"
f_getcwd(buf, sizeof(buf));
printf("%s\n",buf); // "1:/DIR1/DIR2"
while(1){
Idle();
}
}
See also
Last updated: 2020/11/17