UKESF Headstart Summer School / PsiSwarm-Headstart

Dependents:   UKESF_Lab

Fork of PsiSwarmLibrary by James Hilder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers basic.cpp Source File

basic.cpp

00001 /* University of York Robotics Laboratory PsiSwarm Library: Psi-BASIC Interpretter Code
00002  * 
00003  * File: basic.cpp
00004  *
00005  * (C) Dept. Electronics & Computer Science, University of York
00006  * James Hilder, Alexander Horsfield, Alan Millard, Homero Elizondo, Jon Timmis
00007  *
00008  * PsiSwarm Library Version: 0.41
00009  *
00010  * March 2016
00011  *
00012  */
00013  
00014  #include "psiswarm.h"
00015  
00016  LocalFileSystem local("local");
00017  
00018  void read_list_of_file_names()
00019  {
00020     DIR *dp;
00021     struct dirent *dirp;
00022     dp = opendir("/local");
00023     if(dp == NULL) pc.printf("- File handling error: Failed to open directory\n");
00024     debug("- Reading FLASH storage for PsiBasic files\n");
00025     //read all files in MBED root directory and add matching file names in current directory into filename vector
00026     while((dirp = readdir(dp)) != NULL) {
00027         string filename = (string) dirp->d_name;
00028          if (filename.compare(filename.size()-4,4,".PSI") == 0)
00029             {
00030                 psi_basic_file_count ++ ;
00031                 debug("- Found file: %s\n",filename.c_str());
00032                 basic_filenames.push_back(filename);
00033             }
00034     }
00035     closedir(dp);
00036  }
00037  
00038 //....example call in your "main" code somewhere.....
00039  
00040  // read file names into vector of strings
00041