pros::usd namespace

Contents

Functions

std::int32_t pros::usd::is_installed(void)
Checks if the SD card is installed.
std::int32_t pros::usd::list_files(const char* path, char* buffer, std::int32_t len)
Lists the files in a directory specified by the path Puts the list of file names (NOT DIRECTORIES) into the buffer seperated by newlines.

Function documentation

std::int32_t pros::usd::is_installed(void)

Checks if the SD card is installed.

Returns 1 if the SD card is installed, 0 otherwise

Example

void opcontrol() {
  printf("%i", is_installed());
}

std::int32_t pros::usd::list_files(const char* path, char* buffer, std::int32_t len)

Lists the files in a directory specified by the path Puts the list of file names (NOT DIRECTORIES) into the buffer seperated by newlines.

Returns 1 on success or PROS_ERR on failure setting errno

This function uses the following values of errno when an error state is reached:

EIO - Hard error occured in the low level disk I/O layer EINVAL - file or directory is invalid, or length is invalid EBUSY - THe physical drinve cannot work ENOENT - cannot find the path or file EINVAL - the path name format is invalid EACCES - Access denied or directory full EEXIST - Access denied EROFS - SD card is write protected ENXIO - drive number is invalid or not a FAT32 drive ENOBUFS - drive has no work area ENFILE - too many open files

Example

void opcontrol() {
    char* test = (char*) malloc(128);
 pros::usd::list_files("/", test, 128);
 pros::delay(200);
 printf("%s\n", test); //Prints the file names in the root directory seperated by newlines
 pros::delay(100);
 pros::list_files("/test", test, 128);
 pros::delay(200);
 printf("%s\n", test); //Prints the names of files in the folder named test seperated by newlines
 pros::delay(100);
}